2

I am changing the qty of items using ajax, when ajax is successful then i want to refresh my sidebar total.

Minicart updates automatically because of sections but the total does not update.

How can i do this?

  • no solution to this question? – LucScu Dec 1 '16 at 14:59
2

I was doing the same, updating the item quantities in the Shopping Cart page using ajax, after my ajax call I do this:

storage.get(resourceUrlManager.getUrlForCartTotals(quote), false)
       .done(
           function (response) {
               quote.setTotals(response);
           })
       .fail(
           function (response) {
               //do your error handling
       });

In my JS file I imported these to make it works:

'Magento_Checkout/js/model/resource-url-manager','mage/storage' and 'Magento_Checkout/js/model/quote'

Also, storage can be replaced by an ajax request, with the next format:

$.ajax({
        url: resourceUrlManager.getUrlForCartTotals(quote),
        type: 'GET',
        global: false,
        contentType: 'application/json'
        });

but I wanted to keep the Magento style.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.