Add custom item to list
Please contact your CSM or [email protected] to enable this API for your store
swat.addCustomProductToList
Adds a custom product to a List with the given lid
. A custom product may not exist on your storefront's catalog or may be a personalized bundle that doesn't have it's own entry on the catalog. You can use also use it to add one-time customizations on the product that have to be persisted on the shopper's list.
Definition
swat.addCustomProductToList(lid, customItem, onSuccess, onError)
Example
Here's are examples of how you can use this API to add a custom product into a List with and without bundle:
// Define the list id of the list
let lid = "59179e9f-139d-4857-bcdd-3ad88a38b47d" // List ID
let customItemWithBundle = {
"du": "https://urltostore.com/products/rossignol-angus-magtek-snowboard-2016",
"title": "Bundled board and ski",
"price": 1194, // custom item with bundle price as a sum of bundle items' price
"sku": "bundled-3-for-di-1",
"iu": "https://urltostore.com/cdn/shop/products/Untitled-11_copy_copy_copy_36b27ebe-c3da-4219-9c27-ce8be2f10a34_620x620.jpg?v=1692882252",
"bundle": [
{
"title": "Angus Magtek - 156cm",
"price": 199,
"empi": 8577926889765,
"epi": 46505649635621,
"iu": "https://urltostore.com/cdn/shop/products/Untitled-11_copy_copy_copy_36b27ebe-c3da-4219-9c27-ce8be2f10a34_620x620.jpg?v=1692882252",
"uri": "https://urltostore.com/products/rossignol-angus-magtek-snowboard-2016",
"vendor": "Rossignol"
},
{
"title": "84 CA Skis - 170cm",
"price": 448,
"empi": 8577936556325,
"epi": 46505712386341,
"iu": "https://urltostore.com/cdn/shop/products/Untitled-1_copy_copy_copy_620x620.jpg?v=1692882429",
"uri": "https://urltostore.com/products/rossignol-experience-84-ca-flat-2015?variant=46505712451877",
"vendor": "Rossignol"
},
{
"title": "88 BSLT Skis - 172cm",
"price": 547,
"empi": 8577936720165,
"epi": 46505714778405,
"iu": "https://urltostore.com/cdn/shop/products/Untitled-1_copy_copy_copy_copy_620x620.jpg?v=1692882431",
"uri": "https://urltostore.com/products/rossignol-experience-88-bslt-flat-2015?variant=46505714876709",
"vendor": "Rossignol"
}
]
}
// Define success callback
let onSuccess = function (response){
// Successfully added custom list item
// Response will contain the custom item added to the list
console.log(`Successfully added custom product to the list ${lid}`, response);
}
// Define error callback
let onError = function (error){
// Error is an xhrObj
console.log("Error while adding custom product to list", error);
}
// `addCustomProductToList` call
swat.addCustomProductToList(lid, customItemWithoutBundle, onSuccess, onError)
// Define the list id of the list
let lid = "59179e9f-139d-4857-bcdd-3ad88a38b47d" // List ID
let customItemWithoutBundle = {
title: "Title for custom item",
price: 25, //custom price
du: du, // url to bundle product
qty: qty || 1,
};
// Define success callback
let onSuccess = function (response){
// Successfully added custom list item
// Response will contain the custom item added to the list
console.log(`Successfully added custom product to the list ${lid}`, response);
}
// Define error callback
let onError = function (error){
// Error is an xhrObj
console.log("Error while adding custom product to list", error);
}
// `addCustomProductToList` call
swat.addCustomProductToList(lid, customItemWithoutBundle, onSuccess, onError)
Things to Consider
- This API is useful when you want to add a custom item to a List that does not exist on your primary catalog.
- You can add bundle upto 5 products in a custom item
- Use the custom item metadata like
title
,du
to handle the storefront implementation like cart, checkout etc.
API Parameters
Argument | Type | Description |
---|---|---|
lid | guid | Unique id of the List to fetch contents |
customItem | object | Custom List item |
onSuccess | function | Called when the customItem is successfully added. |
onError | function | Called when there is an error while adding customItem to the List. |
Success Response
{
"data": {
"di": "b2743e6f-c045-45d3-81e3-9f81dff06464",
"lity": "customBundle",
"dt": "Bundled board and ski",
"bundle": [
{
"vendor": "Rossignol",
"empi": 8577926889765,
"title": "Angus Magtek - 156cm",
"epi": 46505649635621,
"iu": "https://urltostore.com/cdn/shop/products/Untitled-11_copy_copy_copy_36b27ebe-c3da-4219-9c27-ce8be2f10a34_620x620.jpg?v=1692882252",
"uri": "https://urltostore.com/products/rossignol-angus-magtek-snowboard-2016",
"price": 199
},
{
"vendor": "Rossignol",
"empi": 8577936556325,
"title": "84 CA Skis - 170cm",
"epi": 46505712386341,
"iu": "https://urltostore.com/cdn/shop/products/Untitled-1_copy_copy_copy_620x620.jpg?v=1692882429",
"uri": "https://urltostore.com/products/rossignol-experience-84-ca-flat-2015?variant=46505712451877",
"price": 448
},
{
"vendor": "Rossignol",
"empi": 8577936720165,
"title": "88 BSLT Skis - 172cm",
"epi": 46505714778405,
"iu": "https://urltostore.com/cdn/shop/products/Untitled-1_copy_copy_copy_copy_620x620.jpg?v=1692882431",
"uri": "https://urltostore.com/products/rossignol-experience-88-bslt-flat-2015?variant=46505714876709",
"price": 547
}
],
"cts": 1746358785130,
"empi": "f14b25c8-1331-4822-a6ae-0a3761b0ed34",
"sku": "bundled-3-for-di-1",
"lid": "4887d508-1e1d-4354-8ba4-bd9b1961e46f",
"du": "https://urltostore.com/bundle-handler?sku=bundled-3-for-di-1",
"epi": "e8061182-427f-4d1e-b83e-00c618307d3d",
"uts": 1746358785130,
"iu": "https://urltostore.com/cdn/shop/products/Untitled-11_copy_copy_copy_36b27ebe-c3da-4219-9c27-ce8be2f10a34_620x620.jpg?v=1692882252",
"pr": 1194
}
}
Mandatory checks
- Custom item must have du, title & price
- Custom item bundle allows maximum of 5 products
- Custom item bundle must have title, price, empi, epi, iu, uri
Updated 4 days ago