0

How can I update minicart counter after qty exceeds 99.

Like, If customer adds 10000 qty to cart in minicart it will display 10000 which looks weird, So if total qty in cart exceeds more than 99 then I want to display 99+.

How can I achieve this? Any ideas?

2

You can read More about the knockout.js

(For quantity), Replace span counter number tag with

<span class="counter-number">
            <!-- ko if: getCartParam('summary_count') < 100 -->
                <!-- ko text: getCartParam('summary_count') --><!-- /ko -->
            <!-- /ko -->
            <!-- ko if: getCartParam('summary_count') > 99 -->
                <!-- ko text: '99+' --><!-- /ko -->
            <!-- /ko -->   
 </span>

& for items, replace counter label tag with below code.

   <span class="counter-label">
            <!-- ko if: getCartParam('summary_count') == 1 -->
            <!-- ko i18n: 'item' --><!-- /ko -->
            <!-- /ko -->
            <!-- ko if: getCartParam('summary_count') > 1 -->
              <!-- ko i18n: 'items' --><!-- /ko -->
            <!-- /ko -->
   </span>
2

i think the easiest way to do this is to override vendor\magento\module-checkout\view\frontend\templates\cart\minicart.phtml and make changes in <span class="counter-number">. replace

<span class="counter-number"><!-- ko text: getCartParam('summary_count') --><!-- /ko --></span>   

with:

<span class="counter-number">
<!-- ko if: getCartParam('summary_count') < 100 -->
    <!-- ko text: getCartParam('summary_count') --><!-- /ko -->
<!-- /ko -->
<!-- ko if: getCartParam('summary_count') > 99 -->
    <!-- ko text: '99+' --><!-- /ko -->
<!-- /ko -->   
</span>

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.