Added to Cart From Wishlist Event

Event triggered when adding an Item to cart from Swym Wishlist 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.

{
  "available": true,
  "barcode": null,
  "compare_at_price": null,
  "featured_image": null,
  "id": 41254655393990,
  "inventory_management": "shopify",
  "name": "Ceramic Oval Basin",
  "option1": "Default Title",
  "option2": null,
  "option3": null,
  "options": [
    "Default Title"
  ],
  "price": 30000,
  "public_title": null,
  "quantity_rule": {
    "increment": 1,
    "max": null,
    "min": 1
  },
  "requires_shipping": true,
  "sku": "23",
  "taxable": true,
  "title": "Default Title",
  "weight": 0
}