in

Get Total Price of Cart Including/Excluding VAT/Tax in Magento Minicart Widget

Get Total Price of Cart Including/Excluding VAT/Tax

A quick post here, which is more of a note to myself, because I’ve just spent one hour digging through methods for this. If you want to display the total price including or excluding VAT in Magento, using strictly methods already integrated in Magento, use the below code to call these in a pre-formatted way.

The code displayed below you can use save the output to a variable (e.g. $grandTotal or $subTotal) and manipulate it. You can also use it to display (echo) the output anywhere on your page (e.g. minicart.phtml). Which is what I used it for.

Get Price of all Items in Cart including VAT/Tax

Some themes display the subtotal in minicart.phtml; the widget used to display a summary of the shopping cart in the top-right corner of the page. In particular cases, we want to display the Grand Total, which is the sum of all the items added to the shopping cart including taxes (VAT).

// Get Price of all Items in Cart including VAT/Tax
Mage::helper('checkout')->formatPrice(Mage::getSingleton('checkout/cart')->getQuote()->getGrandTotal()

Get Total Price excluding/without VAT/Tax

If your clientele consists of businesses you might want to change the way your theme displays its totals in the mini-cart. The code below can be used to display or manipulate the Subtotal; which is the sum of all the items added to the cart excluding taxes (VAT).

// Get Total Price excluding/without VAT/Tax
Mage::helper('checkout')->formatPrice(Mage::getSingleton('checkout/cart')->getQuote()->getSubtotal()

I hope this was helpful. Have you found a more efficient way to handle the above, or do you just want to say ‘Thank you’? Feel free to leave a comment!

Buy me a beer?

Do you appreciate my work and support? Please consider supporting me by donating, so I can continue to develop and write useful solutions for you.

Choose amount

Personal Message

Thank you! 🙂

Written by Daan van den Bergh

Magento 2 Back-end Developer with a passion for trainlifting, airplane-gliding, hunting trees and creating fake hobbies.

One Comment

Leave a Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.