How to Change Quantity Without Clicking Update Button in Mini Cart in Magento 2
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
1 2 3 4 5 6 |
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.
Please mention any doubts about the topic in the Comments section below.
I’d be happy to help.
Feel free to share the solution with Magento community via social media.
Thank you.
Sanjay Jethva
Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe.
His passion for Magento 2 and Shopify solutions has made him a trusted source for businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.
Prev
How to Implement No Contact Delivery for Magento 2 Stores to Avoid COVID-19 Spread
How to Install Magento SUPEE 11314 [With or Without SSH]
Next