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.
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityUpdate 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.
Update Wishlist counter
Paste in Your Js file (your custom theme js)
require([
'jquery',
'Magento_Customer/js/customer-data'
], function ($, customerData) {
"use strict";
var sections = ['wishlist'];
customerData.reload(sections, true);
});
This code reload the wishlist item count in every pages...