Callbacks and Functions

The app provides number of Javascript callback functions which can be used for customised user experience development. These are already declared by us. In order to use these functions, all you need is to define them in your theme’s Javascript.

(NOTE: This is an advanced feature meant for professional developers only.)

Functions triggered by click events on wishlist buttons

  • SWCallbackExpressWishlistProductItemAdded: It is triggered when a non-logged user adds an item to wishlist via an individual product page. It is triggered only for the primary product on that page. Secondary items such as Related Products or Recommended products are not catered by it.
  • SWCallbackExpressWishlistProductItemRemoved: It is triggered when a non-logged user removes an item from wishlist via an individual product page. It is triggered only for the primary product on that page. Secondary items such as Related Products or Recommended products are not catered by it.
  • SWCallbackExpressWishlistCollectionItemAdded: It is triggered when a non-logged user adds an item to wishlist via a collection/category page. It is also triggered when secondary items (such as Related Products) are added to wishlist via individual product page.
  • SWCallbackExpressWishlistCollectionItemRemoved: It is triggered when a non-logged user removes an item from wishlist via a collection/category page. It is also triggered when secondary items (such as Related Products) are removed from wishlist via individual product page.
  • SWCallbackCustomerWishlistProductItemAdded: It is triggered when a registered and logged-in user adds an item to wishlist via an individual product page. It is triggered only for the primary product on that page. Secondary items such as Related Products or Recommended products are not catered by it.
  • SWCallbackCustomerWishlistProductItemRemoved: It is triggered when a registered and logged-in user removes an item from wishlist via an individual product page. It is triggered only for the primary product on that page. Secondary items such as Related Products or Recommended products are not catered by it.
  • SWCallbackCustomerWishlistCollectionItemAdded: It is triggered when a registered and logged-in user adds an item to wishlist via a collection/category page. It is also triggered when secondary items (such as Related Products) are added to wishlist via individual product page.
  • SWCallbackCustomerWishlistCollectionItemRemoved: It is triggered when a registered and logged-in user removes an item from wishlist via a collection/category page. It is also triggered when secondary items (such as Related Products) are removed from wishlist via individual product page.

Functions triggered by the load events

  • SWCallbackWishlistButtonLoaded: This function is triggered when the wishlist button has loaded on a page. On pages where wishlist button has not been configured to be displayed, this function is triggered when the App’s script has been fired. Unlike the above functions, this function shall always be triggered across all pages, as long as the app is installed on the store. It can be used to make any changes to the Wishlist button dynamically.
  • WishlistLoadedCallback: This function is triggered when the items of wishlist page have fully loaded. It works for both logged-in and non-logged-in users. This function is triggered only on the default Wishlist page created by the App (e.g. /a/wishlist pages). However, it is not triggered on public wishlist pages (e.g. /a/wishlist/12444322xtssdgszasdadh pages

Function to reload Wishlist buttons

ReloadSmartWishlist: This function would trigger the app and populate the span and div containers with the HTML for wishlist button. This is mostly used when the products are loaded via AJAX. Calling this function adds wishlist button to such products.

It should be noted that unlike the above functions, this is not a callback function and therefore doesn’t need to be defined. It is already defined by the app and just needs to be called.

The safest and preferred way to call this function is as follows:

if (typeof ReloadSmartWishlist !== "undefined" && $.isFunction(ReloadSmartWishlist)) ReloadSmartWishlist();

Leave a Reply

Your email address will not be published. Required fields are marked *