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?

1
  • no solution to this question?
    – LucScu
    Commented Dec 1, 2016 at 14:59

1 Answer 1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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