Remove a product from many lists
Remove a single product from many lists.
swat.removeProductFromLists
Removes a Product from many Lists .
Definition
swat.removeProductFromLists(product, lids, onSuccess, onError)
Example
Here's an example of how you can use this API to remove a Product from many Lists :
// list item object to be removed from lists.
var product = { // item
epi: epi, // unique variant of the product per listid
empi: empi, // product id
du: du // product url.
}
let lids = [`listId1`, `listId2`]; // guids of the lists to remove to max 10 at a time.
// Define success callback
let onSuccess = function (response){
// successfully removed list item from the all of the lists
console.log("Successfully removed a Product from many Lists", response);
}
// Define error callback
let onError = function (error){
// Error is an xhrObj
console.log("Error while adding a Product to many Lists", error);
}
swat.removeProductFromLists(product, lids, onSuccess, onError);
Things to Consider
- You can use this API to remove a product from many lists on a single network request.
- You can only remove a product from up to 10 lists at a time with a single request.
- Checking if the product exists in the lists before removing it will help increase the quality of the custom wishlist implementation and avoid "Unknown-product" errors for your users.
API Parameters
Argument | Type | Description |
---|---|---|
lids | array | Array of List ids from which the product should be removed. |
product | object | Please refer Product |
onSuccess | function | Called when the Product is successfully removed from many Lists. |
onError | function | Called when there is an error while removing a Product from many Lists. |
Success Response
[
{
"_self": "dbs/JkFjAA==/colls/JkFjANdNmCM=/docs/JkFjANdNmCP8YjsCAABADg==/",
"di": "fb283019-487b-4447-99e6-133178f6477e",
"bt": "Swym Marketing",
"_attachments": "attachments/",
"_rid": "JkFjANdNmCP8YjsCAABADg==",
"dt": "1 LIGHT PENDANT",
"cts": 1679637447730,
"empi": 7096252727494,
"_ts": 1679637447,
"sku": "24",
"_etag": "\"1b0008a2-0000-0800-0000-641d3bc70000\"",
"lid": "313bef26-16b4-4861-be1b-c986f6ac5871",
"du": "https://demo.swym.it/products/1-light-pendant",
"pid": "KABSbuGyYCuM6/IV7e7cGxT1978LieU1jRdMt6XhYfo=",
"epi": 41254709264582,
"id": "aad561b5-57dc-4c00-9561-b557dcfc008f",
"uts": 1679637447730,
"_pkey": "fb283019",
"iu": "https://cdn.shopify.com/s/files/1/0534/3635/0662/products/1LIGHTPENDANT_620x620.jpg?v=1637584280",
"_t": 2,
"pr": 150
},
{
"_self": "dbs/JkFjAA==/colls/JkFjANdNmCM=/docs/JkFjANdNmCP9YjsCAABADg==/",
"di": "fb283019-487b-4447-99e6-133178f6477e",
"bt": "Swym Marketing",
"_attachments": "attachments/",
"_rid": "JkFjANdNmCP9YjsCAABADg==",
"dt": "1 LIGHT PENDANT",
"cts": 1679637447775,
"empi": 7096252727494,
"_ts": 1679637447,
"sku": "24",
"_etag": "\"1b000aa2-0000-0800-0000-641d3bc70000\"",
"lid": "b62abea5-370a-4111-aed7-4d7752ff87b7",
"du": "https://demo.swym.it/products/1-light-pendant",
"pid": "KABSbuGyYCuM6/IV7e7cGxT1978LieU1jRdMt6XhYfo=",
"epi": 41254709264582,
"id": "bfd5e44e-359a-417f-95e4-4e359a517f3f",
"uts": 1679637447775,
"_pkey": "fb283019",
"iu": "https://cdn.shopify.com/s/files/1/0534/3635/0662/products/1LIGHTPENDANT_620x620.jpg?v=1637584280",
"_t": 2,
"pr": 150
}
]
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