How to Update Total Using JS File in Magento 2

Use the below code in .js file.
If you have any doubts regarding this post, just mention them in the Comments section below.
Feel free to share the solution with Magento Community via social media.
While working with the cart page and checkout page, the total automatically updates when you enter a correct coupon code or discount code in the default behavior of Magento 2.

Method to Update Total Using JS File in Magento 2

Never miss Magento tips, tricks, tutorials, and news.

Something went wrong.
It’s bad practice to reload the whole page to update the total on modifying any field, and it results in a bad user experience too!
That’s it
Thank you for subscribing.
What if you want to apply that same behavior in your custom discount method, store credit, or rewards? You can update total using JS file in Magento 2, the same as in the default Magento 2.

Get Weekly Updates

The users need not wait while the page reloads to proceed to place the order. Hence, use the below solution to automatically update total using JS file in Magento 2 cart page and checkout page.

I would be happy to help.
Thank You.

/**/

/*.mfp-bg{background:#000000d4}
/*]]>*/

/*.mfp-bg.mfp-ready{opacity:.6}
/*]]>*/

(based on 0 Reviews)