Menu Close
    Hire us Request quote Reading list Switch to dark mode
    lockdownWebkulUp

    Update cart totals by js on checkout page magento2

    If you are working on checkout page functionality, and you are updating the totals by js. After this total is not reflecting/updating on summery block, then to update amount by JS after your request without reloading your page, you can use following process:

    you need to add following code in your js file:


    Here, firstly you need to define js


    after this create objects for the same, i used here defaultTotal and cartCache.

    Now, add these lines in your file after which you want to update the totals.


    cartCache.set(‘totals’, null) : set the cart total to calculate totals again, if not using this line then estimateTotals() returns the totals for cache.

    defaultTotal.estimateTotals(): executing the process to calculate totals.

    Order total in default process:

    . . .
    Subscribe Articles

    Just enter your email below to subscribe and receive weekly updates about the most interesting similar articles.

    You need to accept conditions to receive letters.
    You've Subscribed!

    Share article via

    . . .

    after executing code it will be like:

    Hope this will help you in manage totals of cart.

     

    Thank you.

    . . .

    Comment (1)

    Add Your Comment

  • Andres
    Hi in the past, I am using Magento 2 2.3 and it does not work, could you put the source if it is not too much trouble?
  • Back to Top
    css.php
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just recieved your project brief and our expert will contact you shortly.
    Send Again
    Close