Add product

Add single or multiple products to Save for Later List.

swat.SaveForLater.add

Add a product or products to a Save for Later List from cart.

Definition

swat.SaveForLater.add(lid, products, onSuccess, onError)

Example

// array of products you wish to save for later.
let products = [{
	du: "https://demo.swym.it/products/1200-mm-48-inch-high-speed-ceiling-fan-white-1",
	empi: 7096396546246,
	epi: 41255080132806,
}];

let lid = "7f69f914-d413-48dc-b449-77e9c3ff08e8"; // List ID.

// Success callback.
let onSuccess = function(response) {
	console.log("Successfully Added the products to Save for Later List", response);
}

// Error Callback. 
let onError = function(error) {
	// Error is an xhrObject
	console.log("There was an Error, while Adding products to the Save For Later List", error);
}

// Call the Add function.
swat.SaveForLater.add(lid, products, onSuccess, onError);

🚧

The API requires the product data to be available on the e-commerce platform. You cannot add invalid products.

Adding a product to a Save for Later List that is not present in your ecommerce platform will throw an "unknown product" error.

API Parameters

ArgumentTypeDescription
lidobjectList id of save for later list.
productsarrayArray of Products you wish to add. (Max 10 per request)
onSuccessfunctionCalled when the products are successfully added.
onErrorfunctionCalled when there is an error while adding products to the Save for later List.

Success Response

{
    "itemsadded": [
        {
            "di": "fb283019-487b-4447-99e6-133178f6477e",
            "bt": "Swym Marketing",
            "clbls": [],
            "uid": "8kPqX6/sOYTTOc0WqrpkhmWttqouvi3wygUngPfiHU=",
            "dt": "1200 mm (48 inch) High Speed Ceiling Fan (White)",
            "cts": 1679668563837,
            "empi": 7096396546246,
            "cby": "[email protected]",
            "lid": "7f69f914-d413-48dc-b449-77e9c3ff08e8",
            "du": "https://demo.swym.it/products/1200-mm-48-inch-high-speed-ceiling-fan-white-1",
            "pid": "/IV7e7cGxT1978LieU1jRdMt6XhYfo=",
            "epi": 41255080132806,
            "cprops": {},
            "uts": 1679668563837,
            "iu": "https://cdn.shopify.com/s/files/1/0534/3635/0662/products/1200mm_48inch_HighSpeedCeilingFan_White_620x620.jpg?v=1637592908",
            "qty": 1,
            "uby": "[email protected]",
            "pr": 800.0,
            "vi": null
        }
    ],
    "itemsfailed": []
}

Adding Custom Properties using cprops

The cprops property is useful when you have to add custom logic based on some metafields not available in the product.

It is a custom object that can store keys and values that you would like to retain in the wishlist for each product.

For example, you may want to add specific discount coupons to each product while adding it to the cart.


Other Resources

Product

Is an array containing product object.

Property NameData TypeRequiredDescription
epiint/stringYesVariant id of the product to be added
empiint/stringYesProduct id of the product to be added
dustringYesCanonical uri of the product to be added
qtyintoptionalDefaults to 1. Quantity included for the add action
notestringoptionalOptional note
cpropsobjectoptionalMap of custom fields