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

ArgumentTypeDescription
onSuccessfunctionCalled when the Save for Later List is successfully created.
onErrorfunctionCalled 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

Key NameDescriptions
listList Information on Save for Later List
itemsContains all the items for this user, initially it will be empty.
userinfocontains information on the user.
paginationpagination

List

A simple Javascript object containing parameters required for creating a new List

Property NameData TypeRequiredDescription
lnamestringYesList name - unique for a given user, allows 3-50 characters.
lnotestringoptionalNote you may add to list, that you can fetch at a later time for frontend use
lpropsobjectoptionalCustom object that can store attrbiutes of your choice for each list.
ltystringYesSpecifies 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 NameData TypeRequiredDescription
epiint/stringYesVariant id of the product to be added
empiint/stringYesProduct id of the product to be added
dustringYesCanonical uri of the product to be added
qtyintoptionalDefaults to 1. Quantity included for the add action
notestringoptionalOptional note
cpropsobjectoptionalMap of custom fields
lblsarrayoptionalArray of strings indicating labels, rooms, etc. for HTC. Only one value supported in array. eg: ["Room1"]
_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