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

  1. You can use this API to remove a product from many lists on a single network request.
  2. You can only remove a product from up to 10 lists at a time with a single request.
  3. 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

ArgumentTypeDescription
lidsarrayArray of List ids from which the product should be removed.
productobjectPlease refer Product
onSuccessfunctionCalled when the Product is successfully removed from many Lists.
onErrorfunctionCalled 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 NameData TypeRequiredDescription
product.epiint/stringYesVariant id of the product to be added
product.empiint/stringYesProduct id of the product to be added
product.dustringYesCanonical uri of the product to be added
product.qtyintoptionalDefaults to 1. Quantity included for the add action
product.notestringoptionalOptional note
product.cpropsobjectoptionalMap of custom fields
product.lblsarrayoptionalArray of strings indicating labels, rooms, etc. for HTC. Only one value supported in array. eg: ["Room1"]
product._avbooloptionaltrue 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