I want to show two subtotal prices in the minicart. The plan is to multiply the subtotal price and print it next to the original subtotal price. The price is printed by knockout in the html file magento/vendor/magento/module-tax/view/frontend/web/template/checkout/minicart/subtotal/totals.html which looks like this:

 * Copyright © 2013-2017 Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.

<div class="amount price-container">
    <!-- ko if: displaySubtotal() -->
        <!-- ko if: display_cart_subtotal_excl_tax -->
            <span class="price-wrapper" data-bind="html: cart().subtotal_excl_tax"></span>
        <!-- /ko -->

        <!-- ko if: !display_cart_subtotal_excl_tax && display_cart_subtotal_incl_tax -->
            <span class="price-wrapper" data-bind="html: cart().subtotal_incl_tax"></span>
        <!-- /ko -->

        <!-- ko if: !display_cart_subtotal_excl_tax && !display_cart_subtotal_incl_tax -->
            <span class="price-wrapper price-including-tax"
                  data-bind="attr: { 'data-label': $t('Incl. Tax') }, html: cart().subtotal_incl_tax">

            <span class="price-wrapper price-excluding-tax"
                  data-bind="attr: { 'data-label': $t('Excl. Tax') }, html: cart().subtotal_excl_tax">
        <!-- /ko -->
    <!-- /ko -->
    <!-- ko ifnot: displaySubtotal() -->
        <!-- ko foreach: getRegion('minicart-subtotal-hidden') -->
            <!-- ko template: getTemplate() --><!-- /ko -->
        <!-- /ko -->
    <!-- /ko -->

I can't figure out where (in which file and how) data-bind="html: cart().subtotal_excl_tax" gets the subtotal. Is what I am doing trying to do possible or is there a better way of accomplishing this?


I would suggest to debug below files and it's function:

**getSectionData**  function from **Magento\Checkout\CustomerData\Cart.php** 
**afterGetSectionData** function from **Magento\Tax\Plugin\Checkout\CustomerData\Cart.php**

Hope this helps...

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.