JMega Posted November 16, 2012 Share Posted November 16, 2012 I'm trying to set up a payment module and I need to grab the total taxes and the total shipping costs and pass them along to this 3rd party payment processor. I've got the total amount (including taxes and shipping) by doing the following: number_format($params['cart']->getOrderTotal(true, 3), 2, '.', '') Does anyone know what I should use to get the shipping cost and the amount of tax? Thanks in advance Link to comment Share on other sites More sharing options...
hobo Posted April 12, 2013 Share Posted April 12, 2013 If it helps future searchers - the firsst argument of the call to getOrderTotal is whether to use taxes, and the second determines the value returned. Possible values for the second are: Cart::ONLY_PRODUCTS Cart::ONLY_DISCOUNTS Cart::BOTH Cart::BOTH_WITHOUT_SHIPPING Cart::ONLY_SHIPPING Cart::ONLY_WRAPPING Cart::ONLY_PRODUCTS_WITHOUT_SHIPPING Cart::ONLY_PHYSICAL_PRODUCTS_WITHOUT_SHIPPING So to answer the original question, $params['cart']->getOrderTotal(true, Cart::ONLY_SHIPPING) should return the shipping cost (including taxes). Depending on the tax you're after, something like $params['cart']->getOrderTotal(true, Cart::BOTH) - $params['cart']->getOrderTotal(false, Cart::BOTH) should so the trick. Disclaimer - I haven't tested any of this code; I'm only answering because the question solved a problem for me. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now