Wishlist Updated
An event that keeps an eye on wishlisted products of the app.
Description
The wishlistUpdated event triggers whenever a customer adds or removes products from their wishlist.
Function Signature
VajroSDK.listeners.onWishlistUpdated(() => {
// Write your logic
});| Parameter | Type | Required | Description |
|---|---|---|---|
| Nil | Nil | Nil | This listener does not require any parameter. |
Example Usage
VajroSDK.listeners.onWishlistUpdated(() => {
console.log('Wishlist updated:', VajroSDK.variables.customer.wishlistedProducts);
//to display the number of products added to wishlist
document.getElementById("wishlist_count").innerHTML=JSON.stringify(VajroSDK.variables.customer.wishlistedProducts.length);
});Best Practices
- Live badge updates: Use this event to keep the wishlist badge accurate without page reloads.
- Track engagement: Log wishlist add/remove events for marketing insights.
- Guard for logged-out users: Ensure the customer is logged in before performing wishlist actions.
Caveats
- Global event: Fires on any page where wishlist actions occur.
- Login dependency: Wishlist data is tied to the logged-in customer.
- API sync: Some delays may occur if wishlist data syncs asynchronously with Shopify.
Updated about 1 month ago