Earlier I posted a solution to update mini cart in Magento 2.
Talking about user experience and mini cart, here’s more it in this post.
The below solution allows users to change quantity without clicking the update button in mini cart in Magento 2.
The visitor can change the quantity of items in the text field and hit enter to update the mini cart without having to use the update button.
Reducing the number of clicks pushes conversion and that’s what the below code helps to do:
Method to change quantity without clicking update button in mini cart in Magento 2:
Open sidebar.js
Place the below code at vendor/magento/Module_Checkout/view/frontend/web/js
events['keypress ' + this.options.item.qty] = function (event) { var keycode = (event.keyCode ? event.keyCode : event.which); if(keycode == '13'){ $(this.options.item.qty + "+" +" .update-cart-item").click(); } };
That’s it.
Feel free to share the solution with Magento community via social media.
Thank you.