Remove many products from a list
Remove many products from a list. (Many products from a single list)
swat.removeProductsFromList
Removes many Products from a List in a single call.
Definition
swat.removeProductsFromList(lid, products, onSuccess, onError)
Example
Here's an example of how you can use this API to delete many Products from a List called black friday list
:
// Define the list id of the list
let lid = "59179e9f-139d-4857-bcdd-3ad88a38b47d" // List ID
// Define the products array with 2 products.
let products = [{
du: "https://demo.swym.it/products/1300mm-ceiling-fan",
empi: 7096402444486,
epi: 41255088488646,
}, {
du: "https://demo.swym.it/products/1200-mm-48-inch-high-speed-ceiling-fan-white",
empi: 7096259772614,
epi: 41254731120838
}]
// Define success callback
let onSuccess = function (removedProducts){
// Successfully removed many products from a single list (many items : 1 list)
console.log(`Successfully removed many Products from the List ${lid}`, removedProducts);
}
// Define error callback
let onError = function (error){
// Error is an xhrObj
console.log("Error while removing many Products from the List", error);
}
swat.removeProductsFromList(lid, products, onSuccess, onError);
Things to consider.
- This API is useful when you want to remove many products from a single list at once. (N : 1)
- You can remove up to a maximum of 10 products in a single request.
- Please check if the product exists in all the lists before removal.
- To check if the product exists, you may use the fetchLists API and loop through the contents. Exclude lists if the product is not found.
API Parameters
Argument | Type | Description |
---|---|---|
lid | guid | Unique id of the List to fetch its contents |
products | array | Array of Products Array length - Max 10 at a time as it affects response times |
onSuccess | function | Called when the Products are successfully removed. |
onError | function | Called when there is an error while removing many Products from the List. |
Success Response
Example products array that you want to remove from a specific
[{
"_self": "dbs/JkFjAA==/colls/JkFjANdNmCM=/docs/JkFjANdNmCO7azsCAABADg==/",
"di": "fb283019-487b-4447-99e6-133178f6477e",
"bt": "Swym Marketing",
"_attachments": "attachments/",
"_rid": "JkFjANdNmCO7azsCAABADg==",
"dt": "1300mm Ceiling Fan",
"cts": 1679658412978,
"empi": 7096402444486,
"_ts": 1679658412,
"sku": "35",
"_etag": "\"1e00d9b7-0000-0800-0000-641d8dac0000\"",
"lid": "b62abea5-370a-4111-aed7-4d7752ff87b7",
"du": "https://demo.swym.it/products/1300mm-ceiling-fan",
"pid": "KABSbuGyYCuM6/IV7e7cGxT1978LieU1jRdMt6XhYfo=",
"epi": 41255088488646,
"id": "d52e7640-b977-43cf-ae76-40b977f3cf93",
"uts": 1679658412978,
"_pkey": "fb283019",
"iu": "https://cdn.shopify.com/s/files/1/0534/3635/0662/products/1300mmCeilingFan_620x620.jpg?v=1637592943",
"_t": 2,
"pr": 800
}, {
"_self": "dbs/JkFjAA==/colls/JkFjANdNmCM=/docs/JkFjANdNmCO1azsCAABADg==/",
"di": "fb283019-487b-4447-99e6-133178f6477e",
"bt": "Swym Marketing",
"_attachments": "attachments/",
"_rid": "JkFjANdNmCO1azsCAABADg==",
"dt": "1200 mm (48 inch) High Speed Ceiling Fan (White)",
"cts": 1679658365514,
"empi": 7096259772614,
"_ts": 1679658365,
"sku": "35",
"_etag": "\"1e00cbb5-0000-0800-0000-641d8d7d0000\"",
"lid": "b62abea5-370a-4111-aed7-4d7752ff87b7",
"du": "https://demo.swym.it/products/1200-mm-48-inch-high-speed-ceiling-fan-white",
"pid": "KABSbuGyYCuM6/IV7e7cGxT1978LieU1jRdMt6XhYfo=",
"epi": 41254731120838,
"id": "37e492e5-e098-40ee-a492-e5e09840eea8",
"uts": 1679658365514,
"_pkey": "fb283019",
"iu": "https://cdn.shopify.com/s/files/1/0534/3635/0662/products/1200mm_48inch_DecorativeCeilingFanwithLights_620x620.jpg?v=1637589184",
"_t": 2,
"pr": 800
}]
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