Create a new list of type 'save for later' for a user.
swat.SaveForLater Init
The swat object contains all Save for Later API under the "SaveForLater" object. This is a special object that is separate from lists API, powering the Save for later metrics and actions.
Before you call other APIs such as add, remove, update. you must first Initialise a Save for Later list.
This will provide you with the specific lid
for a type of sfl
This API should be called first before all other Save for Later API.
Definition
swat.SaveForLater.init(onSuccess, onError)
Example
let onSuccess = function(response) {
console.log("Successfully Initialized, And we created a Save for Later List", response);
}
let onError = function(error) {
// Error is an xhrObject
console.log("There was an Error, while creating the Save For Later List", error);
}
// Call the Init function.
swat.SaveForLater.init(onSuccess, onError);
API Parameters
Argument | Type | Description |
---|---|---|
onSuccess | function | Called when the Save for Later List is successfully created. |
onError | function | Called when there is an error while creating the Save for Later List. |
Response
{
"list": {
"di": "fb283019-487b-4447-99e6-133178f6477e",
"lty": "sfl",
"uid": "8kPqqX6/sOYTTOc0WqrpkhmWttqouvi3wygUngPfiHU=",
"cts": 1679667114911,
"lnote": null,
"lname": "My SFL List",
"cby": "ranga",
"lid": "7f69f914-d413-48dc-b449-77e9c3ff08e8",
"pid": "KABSbuGyYCuM6/IV7e7cGxT1978LieU1jRdMt6XhYfo=",
"st": 1,
"cprops": {},
"id": "ba3b87ac-715e-4b9c-bb87-ac715efb9cb0",
"uts": 1679667114911,
"ldesc": {},
"uby": null,
"cfor": null
},
"items": [],
"userinfo": {
"lastlogin": "2023-03-24T14:12:23Z",
"fname": "ranga",
"sw_mkt": null,
"extags": [
"pre-2022-05-11-check"
],
"uid": "8kPqqX6/sOYTTOc0WqrpkhmWttqouvi3wygUngPfiHU=",
"m": null,
"em": "[email protected]",
"cts": 1652286963869,
"lname": "prakash",
"pid": "KABSbuGyYCuM6/IV7e7cGxT1978LieU1jRdMt6XhYfo=",
"uts": 1674475641105,
"acc_mkt": true,
"ut": null,
"prefs": {
"Mediums": {
"email": {
"signuptime": 1673268675254,
"acceptmarketing": true,
"acceptsource": "shopify"
}
}
},
"pd": {
"tags": [
"pre-2022-05-11-check"
],
"addresses": [],
"orders_count": 0,
"state": "enabled",
"accepts_marketing": true,
"updated_at": "2023-01-21T19:05:58+05:30",
"total_spent": "0.00",
"created_at": "2021-09-28T13:53:51+05:30",
"last_order_id": null
}
},
"pagination": {
"totalcount": 0,
"next": null,
"limit": null
}
}
Response Reference
List
A simple Javascript object containing parameters required for creating a new List
Property Name | Data Type | Required | Description |
---|---|---|---|
lname | string | Yes | List name - unique for a given user, allows 3-50 characters. |
lnote | string | optional | Note you may add to list, that you can fetch at a later time for frontend use |
lprops | object | optional | Custom object that can store attrbiutes of your choice for each list. |
lty | string | Yes | Specifies the type of list you want to create, wl - wishlist, sfl - save for later, this is used to create a different type of list separate from the wishlist |
Items
Property Name | Data Type | Required | Description |
---|---|---|---|
epi | int/string | Yes | Variant id of the product to be added |
empi | int/string | Yes | Product id of the product to be added |
du | string | Yes | Canonical uri of the product to be added |
qty | int | optional | Defaults to 1. Quantity included for the add action |
note | string | optional | Optional note |
cprops | object | optional | Map of custom fields |
lbls | array | optional | Array of strings indicating labels, rooms, etc. for HTC. Only one value supported in array. eg: ["Room1"] |
_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 |