Added to Cart From Swym UI
Event triggered when adding an Item to cart from Swym UI.
sw:addedtocart
Can be triggered when a product is added to the user’s cart from Wishlist widget.
Definition
swat.evtLayer.addEventListener('sw:addedtocart', listener)
Example
By adding this event listener, sw:addedtocart
event gets fired from the Swym Default UI on adding a product to the Cart using Swym Wishlist.
// Define eventname
let event = 'sw:addedtocart';
// Define the event listener function
let listener = function(e) {
var data = e.detail.d.productData;
console.log("YAY! Added the product to cart", data);
// update button state here...
};
// Add listener for the 'addedtocart' event to the Swym Event Layer
swat.evtLayer.addEventListener(event, listener);
Success Response
The success response consists of a console.log
message with the text 'YAY! Added the product to cart' and a JSON that contains details of the product added to cart.
The event data contains the response for add to cart action from the underlying ecommerce platform like Shopify or Bigcommerce.
- Shopify AJAX cart API may have different parameters returned compared to Bigcommerce.
- Shopify AJAX cart API response may differ for single item add and multiple items add
Updated 11 days ago