Fetch Saved Cart Products [Beta]

Fetch Products that have been saved to cart by shopper

🚧

Contact support for using Beta Shopper APIs.

swat.shopper.fetchSavedCartProducts

This API retrieves the products that are saved to their cart by a shopper. For logged-in shoppers, all products saved to their cart are retrieved, while for non-logged-in shoppers, all products saved to the cart in their session on the device are retrieved. By default, the API returns a maximum of 12 latest products that are saved to the cart.

Definition

swat.shopper.fetchSavedCartProducts(onSuccess, onError)

Example

Here's an example of how you can use this API to fetch the Saved to-Cart products:

// Define success callback
let onSuccess = function(data) {
  // Successfully fetched the products saved to cart
  console.log("These are the products added to cart by the shopper : ", data.savedCart);
}

// Define error callback
let onError = function(error) {
  // Error is an xhrObject
  console.log("Error while fetching the shopper activity ", error);
}

// Call `shopper.fetchSavedCartProducts` function
swat.shopper.fetchSavedCartProducts(onSuccess, onError);

API Parameters

ArgumentTypeDescription
onSuccessfunctionCalled when the Products saved to cart are fetched successfully.
onErrorfunctionCalled when there is an error while fetching Products saved to cart

Success Response

The success response contains by default, a maximum of 12 Saved to cart products in the savedCart key.

{
  "savedCart": [
    {
      // Product ID from the Platform
      "productId": 7096231231686,
      // Timestamp at which the product was added to cart
      "lastSavedTime": 1709013095458,
      // Varaint ID form the Platform
      "variantId": 41254655393990,
      // Produc URL
      "productURL": "https://demo.swym.it/products/ceramic-oval-basin",
      // Timestamp of the latest order placed with the product after it was added to cart
      "lastOrderTimestamp": 1708426159001,
      // ID of the variant that was ordered after the product was added to cart
      "lastOrderedVariantId": 41254655393990,
      // ID of the latest order placed with the product after it was added to cart
      "lastOrderId": 2849832
    }
  ]
}

Other References

Saved Cart Fields

ArgumentTypeDescription
productIdnumberProduct ID from the Platform
lastSavedTimenumberThe timestamp at which the product was added to cart
productURLstringProduct URL
variantIdnumberVariant ID from the Platform
lastOrderTimestampnumberTimestamp of the latest order placed with the product after it was added to cart
lastOrderIdnumberID of the latest order placed with the product after it was added to cart
lastOrderedVariantIdnumberID of the variant that was ordered after the product was added to cart