The Code must do the talking.

Magento2: Show grand_total in Minicart

3. August 2018

One of our customers needed the minicart to show the grand_total because of the huge quantity discounts they give. The Minicarts view file is Magento_Checkout/templates/cart/minicart.phtml. For the grand_total to work with Javascript you need to add it as data-bind attribute with getCartParam – there is only one problem: grand_total ist not part of the data the Minicart collects. To get it in there you need to overwrite the getSectionData method of \Magento\Checkout\CustomerData\Cart. Here are the two files — if you have questions, just ask them in the comments – I do not explain further cause i hate to read long explanations myself – the code must do the talking.

Tags: ,

2 responses to “Magento2: Show grand_total in Minicart”

  1. Olivier Lance says:

    Hey, thanks a lot for this code sample, it put me on the right track to achieve a similar thing!

    After some research based on your method I think the “proper”/Magento way of doing what you’re doing is to use a Plugin on the \Magento\Checkout\CustomerData\Cart and implement afterGetSectionData:


    class CartTotals
    /* … */
    public function __construct(\Magento\Checkout\Model\Session $checkoutSession) {
    $this->checkoutSession = $checkoutSession;

    public function afterGetSectionData(\Magento\Checkout\CustomerData\Cart $subject, $result)
    $totals = $this->checkoutSession->getQuote()->getTotals();
    if(isset($totals[‘grand_total’])) {
    $result[‘grand_total’] = $totals[‘grand_total’]->getValueInclTax() ?: $totals[‘grand_total’]->getValue();
    return $result;

    Thanks a lot for your help in coming to this solution 🙂

Leave a Reply to Olivier Lance Cancel reply

Your e-mail address will not be published. Required fields are marked *