Update products
Update products or attributes like cprops for a single or multiple products in the Saved for Later list
swat.SaveForLater.update
Update an existing product or existing products in a Save for Later List.
Definition
swat.SaveForLater.update(lid, products, onSuccess, onError)
Example
We update the cprops
object on the below product, this will update its value, you may even store discount coupons, labels, for frontend use inside the cprops
object.
// 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,
cprops : {
custom : "I am newly updated custom key to existing product inside save for later list",
}
}];
let lid = "7f69f914-d413-48dc-b449-77e9c3ff08e8"; // List ID.
// Success callback.
let onSuccess = function(response) {
console.log("Successfully Updated 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 Updating products to the Save For Later List", error);
}
// Call the Add function.
swat.SaveForLater.update(lid,products, onSuccess, onError);
API Parameters
Argument | Type | Description |
---|---|---|
lid | object | List id of save for later list. |
products | array | Array of Products you wish to add. (Max 10 per request) |
onSuccess | function | Called when the Products are successfully added. |
onError | function | Called when there is an error while adding products to the Save for later List. |
Success Response
{
"itemsupdated": [
{
"bt": null,
"clbls": [],
"uid": null,
"empi": 7096396546246,
"cby": null,
"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": {
"custom": "I am newly updated custom key to existing product inside save for later list"
},
"uts": 1679672273209,
"uby": "[email protected]",
"pr": null,
"vi": null
}
],
"itemsfailed": []
}
Each product in the Save for Later list is uniquely identified by the epi,
empi
value pair. Hence, to update the properties for a particular product, make sure to send the correct epi, empi value pair in the API call.
Other Resources
Product
Is an array containing product object.
Property Name | Data Type | Required | Description |
---|---|---|---|
epi | int/string | Yes | Variant id of the product to be added |
empi | int/string | Yes | Product id of the product to be added |
du | string | Yes | Canonical uri of the product to be added |
qty | int | optional | Defaults to 1. Quantity included for the add action |
note | string | optional | Optional note |
cprops | object | optional | Map of custom fields |
Updated over 1 year ago