3

How can we initially disable quantity box (read-only) of mini cart and enable it while clicking edit link for each separate product ?

enter image description here

4

As stated my Mahalakshmi the file of interest is

/magento/module-checkout/view/frontend/web/template/minicart/item/default.html

Make a copy of this file into your custom theme so file is overridden e.g.

app/design/frontend/Vendor/Theme/Magento_Checkout/web/template/minicart/item/default.html

You can then make some basic modifications to this file outlined below.

Disable the Quantity Box

Add disabled attribute to the input box like below:

<input data-bind="attr: {
                       id: 'cart-item-'+item_id+'-qty',
                       'data-cart-item': item_id,
                       'data-item-qty': qty,
                       'data-cart-item-id': product_sku
                       }, value: qty"
                       type="number"
                       size="4"
                       disabled
                       class="item-qty cart-item-qty">

This was around line 74 for me on version 2.2.1.

Add logic to enable quantity box

                <a data-bind="attr: {onclick: 'document.getElementById(\'cart-item-'+item_id+'-qty\').disabled = false;'}" class="action edit">
                    <span data-bind="i18n: 'Edit'"></span>
                </a>

I replaced the data-bind attribute with a new action here to enable the quantity box in relation to the quantity that needed to be edited. This was at about line 98 for me.

  • It is working like charm.. Thanks Brother.... – Vishal Tanna Jan 4 '18 at 9:24
  • 1
    Glad to be of assistance! – harri Jan 4 '18 at 9:24
0

you need to refer qty details in this file

/magento/module-checkout/view/frontend/web/template/minicart/item/default.html
  • Here we have to disable and enable text-box while click on EDIT Link. – Vishal Tanna Jan 4 '18 at 8:40
  • 3
    It is not recommended to edit core file directly. – Kishan Patadia Jan 4 '18 at 8:47

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.