3

I am trying to add products in wishlist using ajax with phtml + Controller. However, the product gets added to wishlist but the counter of wishlist doesn't change.

Is there a way to trigger an update for wishlist counter.

4

Update your js file as

require([
   ....
   'Magento_Customer/js/customer-data'
], function (...,customerData) {
   "use strict";
   ...
   var sections = ['wishlist'];
   customerData.invalidate(sections);
   customerData.reload(sections, true);
   ...
});

Modify above code according to your need and you will get what you need.

1
  • Thanks @user3313626, exactly what I wanted :) – Nausif Jan 11 '19 at 9:47

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.