Update List Item
Update product attributes like cprops, note.
swat.updateListItem
Updates cprops, notes for List Item* or a product in a List** using the given lid
and Product.
Definition
swat.updateListItem(lid, product, onSuccess, onError)
Example
Here's an example of how you can use this API to update a List Item of the List with lid
and with product
object:
// Define the list id of the list to be updated
let lid = "59179e9f-139d-4857-bcdd-3ad88a38b47d"; // lid
// Define the product object
let product = {
epi: epi, // variant id of the product to be updated
empi: empi, // product id of the product to be updated
du: du, // canonical uri of the product to be updated
qty: qty, // quantity
note: note, //optional note
cprops: {} // Optional custom attributes
};
// Define success callback
let onSuccess = function(updatedListItem) {
// executed when successfully updated a list item
console.log("Successfully updated the List Item", updatedListItem);
}
// Define error callback
let onError = function(error) {
// Error is an xhrObject
console.log("Error while updating the List Item", error);
}
// Update a list with the above callbacks, lid and product map
swat.updateListItem(lid, product, onSuccess, onError);
Things to consider
- The updates are limited only to the products inside the list.
- The cprops object has a limit; you cannot add an indefinite amount of data.
- cprops and note is meant only to be used for frontend implementations; we do not support any custom data on our backend; we depend on the platform to give us information.
API Parameters
Argument | Type | Description |
---|---|---|
lid | guid | Unique id of the List to be updated |
product | object | Please refer Product |
onSuccess | function | Called when the List Item is successfully updated. |
onError | function | Called when there is an error while updating the List Item. |
Success Response
The success response contains information about the updated List Item like its empi, epi, product uri, image uri etc. and about the corresponding List, like lid, creation and update timestamps.
This information can be used to retrieve or manipulate the List Item in future API calls.
{
"bt": "Swym Demo",
"cts": 1666196721008,
"di": "c3feba7e-c0e0-47cb-be5e-5c32e688fa84",
"dt": "Striped Bag",
"du": "https://demo.swym.it/products/copy-of-peaks-design-bag?variant=39413927182534",
"empi": 6575309390022,
"epi": 39413927182534,
"id": "24300d50-cdbd-4de4-b00d-50cdbd6de473",
"iu": "https://cdn.shopify.com/s/files/1/0534/3635/0662/products/smartmockups_kh4gut7l_620x620.jpg?v=1616077965",
"lid": "9f63f7b3-2db4-42ae-bf8b-d728484cad60",
"pid": "KABSbuGyYCuM6/IV7e7cGxT1978LieU1jRdMt6XhYfo=",
"pr": 17,
"uts": 1679313702035,
"vi": "Black",
"_pkey": "c3feba7e",
"_t": 2
}
Other References
Product
An object containing params required for creating, updating or deleting list items
let product = {
epi: epi, // one unique list item (empi+epi) per listid
empi: empi,
du: du,
qty: qty,
note: note, //optional
cprops: {} // Optional custom attributes
};
--data-urlencode 'epi: {{epi}}' \ # One unique list item (empi+epi) per listid
--data-urlencode 'empi: {{empi}}' \
--data-urlencode 'du: {{du}}' \
--data-urlencode 'qty: {{qty}}' \
--data-urlencode 'note: {{note}}' \
--data-urlencode 'cprops: {{JSON stringified cprops}}' \ # Optional custom attributes
Property Name | Data Type | Required | Description |
---|---|---|---|
product.epi | int/string | Yes | Variant id of the product to be added |
product.empi | int/string | Yes | Product id of the product to be added |
product.du | string | Yes | Canonical uri of the product to be added |
product.qty | int | optional | Defaults to 1. Quantity included for the add action |
product.note | string | optional | Optional note |
product.cprops | object | optional | Map of custom fields |
product.lbls | array | optional | Array of strings indicating labels, rooms, etc. for HTC. Only one value supported in array. eg: ["Room1"] |
product._av | bool | optional | true if the list action was done without user explicitly picking a variant. Can be used by Wishlist UX to require user to pick variant before adding to cart |
Updated over 1 year ago