I have included + and - to increment and decrement the quantity of a product in the cart page. Now i need to update it automatically without clicking the update shopping cart button. How can i do that? Kindly help me to fix this problem
Hello @anand_v
You can follow below URL for your reference:
https://webkul.com/blog/update-item-quantity-minicart-magento2/
Let me know if you still face any issue.
Kudos and accept it as a solution if it works. Cheers coding
Thanks @Manish Mittal for your response.
I had tried using the first link (stackexchange.com). It increments and decrements the quantity. But i need to update the cart automatically once i clicks the +/- button. If i clicks the +/- button, the page has to be load and the cart value needs to be changed. I am stuck on that updation. Kindly help if you know the solution for that.
@anand_v, Try this https://stackoverflow.com/questions/40002976/magento-2-reload-totals-cart-after-ajax-change-quantity
Refused to execute script from 'http://127.0.0.1/magento/pub/static/frontend/Samplestore/theme/en_US/custom.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
require.js:141 Uncaught Error: Script error for: custom
http://requirejs.org/docs/errors.html#scripterror
at makeError (require.js:166)
at HTMLScriptElement.onScriptError (require.js:1681)
I have got these errors in the console.
Can you please share the details of Network tab (Chrome debug toolbar) as well?
It seems request should return content in some format (like JSON) & its returning in another format (Might be due to 404 status OR something else).
Hi @ashishhbti. Please find below the screenshot.
It seems that you have placed your js file on the wrong location.
Currently, your js file location is
http://127.0.0.1/magento/app/design/frontend/Samplestore/theme/custom.js
But it must be as given below
http://127.0.0.1/magento/app/design/frontend/Samplestore/theme/web/js/custom.js
Hi @Mayur Bhuva
No i have placed in the correct location.
i.e., in the
http://127.0.0.1/magento/app/design/frontend/Samplestore/theme/web/js/custom.js
Please update your code here so It will be very useful for everyone to answer.