Delete From List
Delete a product from a list.
swat.deleteFromList
Deletes a Product from a List with the given lid
.
Definition
swat.deleteFromList(lid, product, onSuccess, onError)
Example
Here's an example of how you can use this API to delete a Product from a List called black friday list
:
// Define the list id of the list to be updated
let lid = "59179e9f-139d-4857-bcdd-3ad88a38b47d"; // lid
// Define the Product to be deleted
let product = {
epi: epi, // unique variant id per listid
empi: empi, // product id
du: du // product url.
};
// Define success callback
let onSuccess = function(deletedProduct) {
// Executed when product is successfully deleted
console.log("Successfully deleted the Product", deletedProduct);
}
// Define error callback
let onError = function(error) {
// Error is an xhrObject
console.log("Error while deleting the Product", error);
}
// Call `deleteFromList` using the above callbacks, lid and listItem
swat.deleteFromList(lid, product, onSuccess, onError);
API Parameters
Argument | Type | Description |
---|---|---|
lid | guid | Unique id of the List to fetch contents |
listItem | object | Please refer Product |
onSuccess | function | Called when the Product is successfully deleted from the List. |
onError | function | Called when there is an error while deleting the Product. |
Sample Response
[
{
"_self": "dbs/JkFjAA==/colls/JkFjANdNmCM=/docs/JkFjANdNmCMwXu0CAACABw==/",
"di": "c3feba7e-c0e0-47cb-be5e-5c32e688fa84",
"bt": "Swym Marketing",
"_attachments": "attachments/",
"_rid": "JkFjANdNmCMwXu0CAACABw==",
"dt": "12 Inches Round Rose Gold Frame Wall Mirror",
"cts": 1680008384993,
"empi": 7096437407942,
"_ts": 1680008384,
"sku": "45",
"_etag": "\"74018012-0000-0800-0000-6422e4c00000\"",
"lid": "59179e9f-139d-4857-bcdd-3ad88a38b47d",
"du": "https://demo.swym.it/products/12-inches-round-rose-gold-frame-wall-mirror",
"pid": "KABSbuGyYCuM6/IV7e7cGxT1978LieU1jRdMt6XhYfo=",
"epi": 41255230701766,
"id": "d71c2732-89df-4861-9c27-3289df4861ca",
"uts": 1680008384993,
"_pkey": "c3feba7e",
"iu": "https://cdn.shopify.com/s/files/1/0534/3635/0662/products/12InchesRoundRoseGoldFrameWallMirror_620x620.jpg?v=1637593774",
"_t": 2,
"pr": 200
}
]
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