1

I need to get base subtotal including tax. This

Mage::helper('checkout/cart')->getQuote()->getBaseSubtotal()

will show subtotal without tax, even if config Display Subtotal is set to Including tax.

This

$totals = Mage::getSingleton('checkout/cart')->getQuote()->getTotals();
$totals["subtotal"]->getValue()

will show subtotal with tax (if config Display Subtotal is set to Including tax).

But I can not find any method to display base subtotal with tax. Does anybody have any idea?

tnx

1

Try the code below:

$quote = Mage::helper('checkout/cart')->getQuote();
$tax = $quote->getGrandTotal() - $quote->getBaseSubtotal();

EDIT:

I just found a more elegant solution:

Mage::helper('checkout')->getQuote()->getShippingAddress()->getTaxAmount();
7
  • There is no such data inside the object, it returns null.
    – JohnyFree
    Mar 23 '16 at 21:09
  • Hmm, you need to check all the attributes on the object then. Try: print_r(Mage::helper('checkout/cart')->getQuote()->getData())
    – Zach L
    Mar 23 '16 at 21:21
  • I already checked it and I don't find any useful information excepting base_to_quote_rate. But if I want to use this data I need to calculate default currency in reverse order which I am not sure how.
    – JohnyFree
    Mar 23 '16 at 21:37
  • The new code should work
    – Zach L
    Mar 23 '16 at 21:39
  • Thank you but this is wrong. Grand total is different than subtotal. Grand total calculates also discounts which is not included in subtotal. You can not calculate subtotal from grandtotal.
    – JohnyFree
    Mar 23 '16 at 21:47
1

Found the way:

$totals = Mage::getSingleton('checkout/cart')->getQuote()->getTotals();
$rate = Mage::helper('checkout/cart')->getQuote()->getData('base_to_quote_rate');
$subtotalIncTax = $totals["subtotal"]->getValue()/$rate;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.