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

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

{
    "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 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