Magento – Magento2: How to show subtotal in minicart

cartmagento2

I'm trying to show subtotal in minicart block. I've overridden minicart.phtml in my theme and added the below code:

<span data-bind="html: getCartParam('subtotal_excl_tax'), blockLoader: isLoading"></span>

Its showing subtotal on page refresh. But when I add product in the cart the amount doesn't load by Ajax.

Can anyone help me in this?

Thanks in advance.

Best Answer

Subtotal along with counter

<span class="counter qty empty"
      data-bind="css: { empty: !!getCartParam('summary_count') == false }, blockLoader: isLoading">
    <span class="counter-number">
    <!-- ko ifnot: getCartParam('summary_count') -->
        <!-- ko text: '0' --><!-- /ko -->
    <!-- /ko -->
    <!-- ko if: getCartParam('summary_count') -->
        <!-- ko text: getCartParam('summary_count') --><!-- /ko -->
    <!-- /ko -->
    </span>
    <span class="counter-label">
    <!-- ko if: getCartParam('summary_count') -->
        <!-- ko text: getCartParam('summary_count') --><!-- /ko -->
        <!-- ko i18n: 'items' --><!-- /ko -->
    <!-- /ko -->
    </span>
    <span class="counter-number" data-bind="html: getCartParam('subtotal')"></span>
</span>
Related Topic