How to display prices including tax and special price in Magento 2

I was stuck trying to display the original price of an item in the mini-cart in Magento 2.
Here is my solution, which can also be used elsewhere.

Add to your theme Magento_Weee/templates/checkout/cart/item/price/sidebar.phtml

Add the following code appropriately :

// obtain final and normal price
$finalPrice = $item->getProduct()->getFinalPrice();
$normalPrice = $item->getProduct()->getPrice();

// calculate original price of the item including tax
// first load the relevant product using object manager - Magento2
$om = \Magento\Framework\App\ObjectManager::getInstance();
$aproduct = $om->create('Magento\Catalog\Model\Product')->load($item_id);
// grab price info - original price and special price (if there is one)

// display as necessary


Important useful note: if testing the mini-cart - annoyingly in Magento 2 it's Javascript generated and cached by the browser. So you either have keep clearing your browser cache OR (much easier) switch the store view and switch it back again and it'll re-generate.

Leave a Reply