Skip to main content

Cart

The Cart API is used to interact with a cart during a customer's session. This guide shows how to use the Cart API to add, update, and delete cart line items, and update cart notes.

Get the cart

GET /{locale}/api/cart

Use the GET /{locale}/api/cart endpoint to get the cart as JSON.

All monetary properties are returned in the customer's presentment currency. To check the customer's presentment currency, you can use the currency field in the response when you have added other markets.

Below is a simplified GET request using the fetch API. The Content-Type should be set to application/json in the headers object. The response is the JSON of the line items associated.

Example request

Example request
fetch(window.SHOPLAZZA.routes.root + '/api/cart', {
headers: {
'Content-Type': 'application/json'
}
})
.then((response) => response.json())
.then((data) => {
// do something...
});

Response

  • cart object
    line_items object[]

    List of line items.

  • Array [
  • idstring

    ID of the line item.

    item_idstring
    product_idstring

    ID of the product.

    variant_idstring

    ID of the variant.

    quantitystring

    Quantity of the item.

    notestring

    Note attached to the line item.

    propertiesstring

    Custom properties of the line item, returned as a JSON string. Parse it before use.

    customboolean

    Whether the line item is a custom item.

    product_titlestring

    Title of the product.

    product_handlestring

    Handle of the product.

    product_urlstring

    Relative URL of the product page.

    variant_titlestring

    Title of the variant, for example Blue, Size M.

    product_typestring

    Product type.

    pricestring

    Price of a single unit of the line item.

    compare_at_pricestring

    Compare-at price of the item.

    origin_pricestring
    line_pricestring

    Combined price of all units in this line item, before discounts.

    original_line_pricenumber

    Original price of the line item before discounts.

    saved_pricenumber

    Amount saved on this line item.

    final_line_pricestring

    Combined price of all units in this line item, after line-level discounts.

    final_pricestring

    Price of a single unit of this line item, after line-level discounts.

    discount_applicationsundefined[]

    Discounts applied to this object.

    fixed_discount_totalstring
    discount_totalstring

    Total discount applied.

    discount_idstring

    ID of the discount applied.

    availableboolean

    Whether the item can be purchased.

    available_quantitynumber

    Quantity still available for purchase.

    can_buyboolean

    Whether the variant of the line item can be sold.

    weightstring

    Weight of the variant.

    weight_unitstring

    Unit of the weight, for example kg.

    skustring

    SKU of the variant, used for inventory tracking.

    spustring

    SPU of the product.

    requires_shippingboolean

    Whether shipping is required.

    taxableboolean

    Whether tax is charged.

    image object

    Image of the line item's variant.

    srcstring

    URL of the image.

    pathstring

    Path of the image file on the image server.

    widthnumber

    Width of the image, in pixels.

    heightnumber

    Height of the image, in pixels.

    altstring

    Alt text of the image.

    options object[]

    Option values of the line item's variant.

  • Array [
  • namestring

    Name of the product option, for example Color.

    valuestring

    Value selected for this product option.

  • ]
  • wholesale_price object[]

    Wholesale price tiers.

  • Array [
  • min_quantitynumber

    Minimum quantity required for this wholesale tier.

    pricestring

    Unit price of this wholesale tier.

  • ]
  • parts_pricestring
    product_tagsundefined[]

    Tags of the product.

    publishedboolean

    Whether the resource is published.

    published_atstring

    Publication time, in ISO-8601 format.

    inventory_quantitynumber

    Inventory quantity.

    inventory_policystring

    Whether the product keeps selling when it is out of stock.

    inventory_trackingboolean

    Whether inventory tracking is enabled.

    cost_pricestring

    Cost price of the variant.

    vendorstring

    Vendor of the product.

    vendor_urlstring

    URL of the product vendor.

    barcodestring

    Barcode of the variant.

    mixed_wholesaleboolean

    Whether mixed wholesale is supported.

    tax_codestring
    retail_pricestring

    Retail price in the store's main currency unit.

    item_textstring
    disabledboolean
    is_free_giftboolean

    Whether the item is a free gift.

    custom_discountsundefined[]
  • ]
  • ineffectivesundefined[]

    Line items in the cart that can no longer be purchased.

    discount_applicationsundefined[]

    Discounts applied to this object.

    attributesundefined[]
    total_discountstring

    Total amount saved by all discounts on the cart.

    discount_line_item_pricestring

    Discounted total for the applied discounts.

    currencystring

    Currency of the cart, for example USD.

    original_line_pricestring

    Original price of the line item before discounts.

    original_total_pricestring

    Total price of the cart before any discounts.

    line_pricestring

    Combined price of all units in this line item, before discounts.

    total_pricestring

    Total price of the cart after discounts.

    notestring

    Note attached to the object.

    created_atstring

    Creation time, in ISO-8601 format.

    updated_atstring

    Last update time, in ISO-8601 format.

    item_countnumber

    Number of items in the cart.

    total_weightnumber

    Total weight of all items in the cart.

    invalid_msgstring
    identity_cart_idstring

    Identifier of the cart. Use it to link a cart to the order it becomes.

    user_idstring

    ID of the signed-in customer. Absent for guests.

Add a variant to the cart

POST /{locale}/api/cart

Use the POST /{locale}/api/cart endpoint to add a single variant to the cart.

Example request

If an item is already in the cart, then quantity is added to the current quantity for that item.

Example request
const data = {
product_id: "b1ab6324-ae4f-4cca-907e-18af16839447",
variant_id: "4a3d825c-2fac-4f72-a68b-b8604b0935c4",
quantity: 1,
refer_info: {
source: "add_to_cart"
},
properties: {
Engraving: "Happy Birthday",
_design_id: "dsg_8f21c"
}
};

fetch(window.SHOPLAZZA.routes.root + '/api/cart', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
})
.then((response) => response.json())
.then((data) => {
// do something...
})
.catch((error) => {
console.error('Error: ', error);
});

Request parameters

    product_idstring

    The product id of the variant.

    quantitynumber

    The quantity that needs to add to the cart.

    variant_idstring

    The variant id.

    refer_info object

    The refer info for the source of the request. It has a source property that possible values: add_to_cart, buy_now, or cart.

    sourcestring
    propertiesobject

    Custom properties to attach to the line item, such as customization options. They stay on the line item through to the order.

note

A line item is identified by its variant together with its properties. Adding the same variant with different properties creates a second line item instead of increasing the quantity of the first one.

In responses, properties comes back as a JSON string, so parse it before reading keys. A line added without properties comes back as an empty string, so check for a value first and guard against a parsed result that is not a plain object.

A key that starts with an underscore is still returned by this API, but it is never displayed to the shopper or in the admin. For the full flow, from writing properties on the product page to reading them back off the order, see Add custom properties to cart and orders.

Response

    statestring

    Request result flag; success or 0 means the request succeeded.

    messagestring

    Result message returned with the response.

    errorsundefined[]

    List of errors returned when the request fails.

    data object

    The response payload.

    items object[]

    List of line items in the cart.

  • Array [
  • idstring

    ID of the line item.

    item_idstring
    product_idstring

    ID of the product.

    variant_idstring

    ID of the variant.

    quantitynumber

    Quantity of the item.

    notestring

    Note attached to the line item.

    propertiesstring

    Custom properties of the line item, returned as a JSON string. Parse it before use.

    customboolean

    Whether the line item is a custom item.

    product_titlestring

    Title of the product.

    product_handlestring

    Handle of the product.

    product_urlstring

    Relative URL of the product page.

    variant_titlestring

    Title of the variant, for example Blue, Size M.

    product_typestring

    Product type.

    pricestring

    Price of a single unit of the line item.

    compare_at_pricestring

    Compare-at price of the item.

    origin_pricestring
    availableboolean

    Whether the item can be purchased.

    available_quantitynumber

    Quantity still available for purchase.

    weightstring

    Weight of the variant.

    weight_unitstring

    Unit of the weight, for example kg.

    skustring

    SKU of the variant, used for inventory tracking.

    spustring

    SPU of the product.

    requires_shippingboolean

    Whether shipping is required.

    taxableboolean

    Whether tax is charged.

    image object

    Image of the line item's variant.

    srcstring

    URL of the image.

    pathstring

    Path of the image file on the image server.

    widthnumber

    Width of the image, in pixels.

    heightnumber

    Height of the image, in pixels.

    altstring

    Alt text of the image.

    options object[]

    Option values of the line item's variant.

  • Array [
  • namestring

    Name of the product option, for example Color.

    valuestring

    Value selected for this product option.

  • ]
  • wholesale_price object[]

    Wholesale price tiers.

  • Array [
  • min_quantitynumber

    Minimum quantity required for this wholesale tier.

    pricestring

    Unit price of this wholesale tier.

  • ]
  • product_tagsundefined[]

    Tags of the product.

    publishedboolean

    Whether the resource is published.

    published_atstring

    Publication time, in ISO-8601 format.

    inventory_quantitynumber

    Inventory quantity.

    inventory_policystring

    Whether the product keeps selling when it is out of stock.

    inventory_trackingboolean

    Whether inventory tracking is enabled.

    cost_pricestring

    Cost price of the variant.

    vendorstring

    Vendor of the product.

    vendor_urlstring

    URL of the product vendor.

    barcodestring

    Barcode of the variant.

    mixed_wholesaleboolean

    Whether mixed wholesale is supported.

    tax_codestring
    retail_pricestring

    Retail price in the store's main currency unit.

    add_quantitystring
    disabledboolean
  • ]

Add one or more variants to the cart

POST /{locale}/api/cart/batch

Use the POST /{locale}/api/cart/batch endpoint to add one or multiple variants to the cart.

Example request

If an item is already in the cart, then quantity is added to the current quantity for that item.

Example request
const data = {
line_items: [
{
product_id: "b1ab6324-ae4f-4cca-907e-18af16839447",
variant_id: "4a3d825c-2fac-4f72-a68b-b8604b0935c4",
quantity: 1,
properties: {
Engraving: "Happy Birthday"
}
},
{
quantity: 2,
product_id: "588ed0ce-40af-44c7-8dea-afa18b489ef8",
variant_id: "83196e5a-b25f-42c3-8df5-359d83ea7ae8"
}
]
}

fetch(window.SHOPLAZZA.routes.root + '/api/cart/batch', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
})
.then((response) => response.json())
.then((data) => {
// do something...
})
.catch((error) => {
console.error('Error: ', error);
});

Request parameters

    line_items object[]

    List of line items.

  • Array [
  • product_idstring

    ID of the product to add.

    variant_idstring

    ID of the variant to add.

    quantitynumber

    Quantity to add.

    propertiesobject

    Custom properties to attach to the line item.

  • ]

Response

    items object[]

    List of line items in the cart.

  • Array [
  • idstring

    ID of the line item.

    item_idstring
    product_idstring

    ID of the product.

    variant_idstring

    ID of the variant.

    quantitynumber

    Quantity of the item.

    notestring

    Note attached to the line item.

    propertiesstring

    Custom properties captured on the line item.

    customboolean

    Whether the line item is a custom item.

    product_titlestring

    Title of the product.

    product_handlestring

    Handle of the product.

    product_urlstring

    Relative URL of the product page.

    variant_titlestring

    Title of the variant, for example Blue, Size M.

    product_typestring

    Product type.

    pricestring

    Price of a single unit of the line item.

    compare_at_pricestring

    Compare-at price of the item.

    origin_pricestring
    availableboolean

    Whether the item can be purchased.

    available_quantitynumber

    Quantity still available for purchase.

    weightstring

    Weight of the variant.

    weight_unitstring

    Unit of the weight, for example kg.

    skustring

    SKU of the variant, used for inventory tracking.

    spustring

    SPU of the product.

    requires_shippingboolean

    Whether shipping is required.

    taxableboolean

    Whether tax is charged.

    image object

    Image of the line item's variant.

    srcstring

    URL of the image.

    pathstring

    Path of the image file on the image server.

    widthnumber

    Width of the image, in pixels.

    heightnumber

    Height of the image, in pixels.

    altstring

    Alt text of the image.

    options object[]

    Option values of the line item's variant.

  • Array [
  • namestring

    Name of the product option, for example Color.

    valuestring

    Value selected for this product option.

  • ]
  • wholesale_price object[]

    Wholesale price tiers.

  • Array [
  • min_quantitynumber

    Minimum quantity required for this wholesale tier.

    pricestring

    Unit price of this wholesale tier.

  • ]
  • product_tagsundefined[]

    Tags of the product.

    publishedboolean

    Whether the resource is published.

    published_atstring

    Publication time, in ISO-8601 format.

    inventory_quantitynumber

    Inventory quantity.

    inventory_policystring

    Whether the product keeps selling when it is out of stock.

    inventory_trackingboolean

    Whether inventory tracking is enabled.

    cost_pricestring

    Cost price of the variant.

    vendorstring

    Vendor of the product.

    vendor_urlstring

    URL of the product vendor.

    barcodestring

    Barcode of the variant.

    mixed_wholesaleboolean

    Whether mixed wholesale is supported.

    tax_codestring
    retail_pricestring

    Retail price in the store's main currency unit.

    add_quantitystring
    disabledboolean
  • ]

Set the quantity of several line items

POST /{locale}/api/cart/update

Use the POST /{locale}/api/cart/update endpoint to set the quantity of one or more line items that are already in the cart. Unlike POST /{locale}/api/cart, the quantity you send replaces the current quantity instead of being added to it.

Example request

Example request
const data = {
line_items: [
{
product_id: "b1ab6324-ae4f-4cca-907e-18af16839447",
variant_id: "4a3d825c-2fac-4f72-a68b-b8604b0935c4",
quantity: 1
}
]
};

fetch(window.SHOPLAZZA.routes.root + '/api/cart/update', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
})
.then((response) => response.json())
.then((data) => {
// do something...
});

Request parameters

    line_items object[]

    The line items to update.

  • Array [
  • product_idstring

    The product id of the variant.

    variant_idstring

    The variant id.

    quantitynumber

    The new quantity of the line item.

  • ]

Response

  • cart object
    line_items object[]

    List of line items.

  • Array [
  • idstring

    ID of the line item.

    item_idstring
    product_idstring

    ID of the product.

    variant_idstring

    ID of the variant.

    quantitystring

    Quantity of the item.

    notestring

    Note attached to the line item.

    propertiesstring

    Custom properties captured on the line item.

    customboolean

    Whether the line item is a custom item.

    product_titlestring

    Title of the product.

    product_handlestring

    Handle of the product.

    product_urlstring

    Relative URL of the product page.

    variant_titlestring

    Title of the variant, for example Blue, Size M.

    product_typestring

    Product type.

    pricestring

    Price of a single unit of the line item.

    compare_at_pricestring

    Compare-at price of the item.

    origin_pricestring
    line_pricestring

    Combined price of all units in this line item, before discounts.

    original_line_pricenumber

    Original price of the line item before discounts.

    saved_pricenumber

    Amount saved on this line item.

    final_line_pricestring

    Combined price of all units in this line item, after line-level discounts.

    final_pricestring

    Price of a single unit of this line item, after line-level discounts.

    discount_applicationsundefined[]

    Discounts applied to this object.

    fixed_discount_totalstring
    discount_totalstring

    Total discount applied.

    discount_idstring

    ID of the discount applied.

    availableboolean

    Whether the item can be purchased.

    available_quantitynumber

    Quantity still available for purchase.

    can_buyboolean

    Whether the variant of the line item can be sold.

    weightstring

    Weight of the variant.

    weight_unitstring

    Unit of the weight, for example kg.

    skustring

    SKU of the variant, used for inventory tracking.

    spustring

    SPU of the product.

    requires_shippingboolean

    Whether shipping is required.

    taxableboolean

    Whether tax is charged.

    image object

    Image of the line item's variant.

    srcstring

    URL of the image.

    pathstring

    Path of the image file on the image server.

    widthnumber

    Width of the image, in pixels.

    heightnumber

    Height of the image, in pixels.

    altstring

    Alt text of the image.

    options object[]

    Option values of the line item's variant.

  • Array [
  • namestring

    Name of the product option, for example Color.

    valuestring

    Value selected for this product option.

  • ]
  • wholesale_price object[]

    Wholesale price tiers.

  • Array [
  • min_quantitynumber

    Minimum quantity required for this wholesale tier.

    pricestring

    Unit price of this wholesale tier.

  • ]
  • parts_pricestring
    product_tagsundefined[]

    Tags of the product.

    publishedboolean

    Whether the resource is published.

    published_atstring

    Publication time, in ISO-8601 format.

    inventory_quantitynumber

    Inventory quantity.

    inventory_policystring

    Whether the product keeps selling when it is out of stock.

    inventory_trackingboolean

    Whether inventory tracking is enabled.

    cost_pricestring

    Cost price of the variant.

    vendorstring

    Vendor of the product.

    vendor_urlstring

    URL of the product vendor.

    barcodestring

    Barcode of the variant.

    mixed_wholesaleboolean

    Whether mixed wholesale is supported.

    tax_codestring
    retail_pricestring

    Retail price in the store's main currency unit.

    item_textstring
    disabledboolean
    is_free_giftboolean

    Whether the item is a free gift.

    custom_discountsundefined[]
  • ]
  • ineffectivesundefined[]

    Line items in the cart that can no longer be purchased.

    discount_applicationsundefined[]

    Discounts applied to this object.

    attributesundefined[]
    total_discountstring

    Total amount saved by all discounts on the cart.

    discount_line_item_pricestring

    Discounted total for the applied discounts.

    currencystring

    Currency of the cart, for example USD.

    original_line_pricestring

    Original price of the line item before discounts.

    original_total_pricestring

    Total price of the cart before any discounts.

    line_pricestring

    Combined price of all units in this line item, before discounts.

    total_pricestring

    Total price of the cart after discounts.

    notestring

    Note attached to the object.

    created_atstring

    Creation time, in ISO-8601 format.

    updated_atstring

    Last update time, in ISO-8601 format.

    item_countnumber

    Number of items in the cart.

    total_weightnumber

    Total weight of all items in the cart.

    invalid_msgstring
    identity_cart_idstring

    Identifier of the cart. Use it to link a cart to the order it becomes.

    user_idstring

Set the quantity of one line item

PATCH /{locale}/api/cart/{variant_id}

Use the PATCH /{locale}/api/cart/{variant_id} endpoint to update the cart's line item quantities.

Example request

If an item is already in the cart, then quantity is equal to the new quantity quantity for that item.

Example request
const data = {
id: "298422_d41d8cd98f00b204e9800998ecf8427e",
product_id: "588ed0ce-40af-44c7-8dea-afa18b489ef8",
variant_id: "83196e5a-b25f-42c3-8df5-359d83ea7ae8",
quantity: 3,
properties: {
Engraving: "Happy Anniversary"
}
};

fetch(window.SHOPLAZZA.routes.root + '/api/cart/83196e5a-b25f-42c3-8df5-359d83ea7ae8', {
method: 'PATCH',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
})
.then((response) => response.json())
.then((data) => {
// do something...
})
.catch((error) => {
console.error('Error: ', error);
});

Request parameters

    variant_idstring

    ID of the variant. Send it in the path and in the request body.

    idstring

    ID of the line item to update, taken from the id of a line item in the cart.

    product_idstring

    ID of the product.

    quantitynumber

    Quantity of the item.

    propertiesobject

    Custom properties of the line item. What you send replaces the properties the line item already has.

Response

  • cart object
    line_items object[]

    List of line items.

  • Array [
  • idstring

    ID of the line item.

    item_idstring
    product_idstring

    ID of the product.

    variant_idstring

    ID of the variant.

    quantitystring

    Quantity of the item.

    notestring

    Note attached to the line item.

    propertiesstring

    Custom properties captured on the line item.

    customboolean

    Whether the line item is a custom item.

    product_titlestring

    Title of the product.

    product_handlestring

    Handle of the product.

    product_urlstring

    Relative URL of the product page.

    variant_titlestring

    Title of the variant, for example Blue, Size M.

    product_typestring

    Product type.

    pricestring

    Price of a single unit of the line item.

    compare_at_pricestring

    Compare-at price of the item.

    origin_pricestring
    line_pricestring

    Combined price of all units in this line item, before discounts.

    original_line_pricenumber

    Original price of the line item before discounts.

    saved_pricenumber

    Amount saved on this line item.

    final_line_pricestring

    Combined price of all units in this line item, after line-level discounts.

    final_pricestring

    Price of a single unit of this line item, after line-level discounts.

    discount_applicationsundefined[]

    Discounts applied to this object.

    fixed_discount_totalstring
    discount_totalstring

    Total discount applied.

    discount_idstring

    ID of the discount applied.

    availableboolean

    Whether the item can be purchased.

    available_quantitynumber

    Quantity still available for purchase.

    can_buyboolean

    Whether the variant of the line item can be sold.

    weightstring

    Weight of the variant.

    weight_unitstring

    Unit of the weight, for example kg.

    skustring

    SKU of the variant, used for inventory tracking.

    spustring

    SPU of the product.

    requires_shippingboolean

    Whether shipping is required.

    taxableboolean

    Whether tax is charged.

    image object

    Image of the line item's variant.

    srcstring

    URL of the image.

    pathstring

    Path of the image file on the image server.

    widthnumber

    Width of the image, in pixels.

    heightnumber

    Height of the image, in pixels.

    altstring

    Alt text of the image.

    options object[]

    Option values of the line item's variant.

  • Array [
  • namestring

    Name of the product option, for example Color.

    valuestring

    Value selected for this product option.

  • ]
  • wholesale_price object[]

    Wholesale price tiers.

  • Array [
  • min_quantitynumber

    Minimum quantity required for this wholesale tier.

    pricestring

    Unit price of this wholesale tier.

  • ]
  • parts_pricestring
    product_tagsundefined[]

    Tags of the product.

    publishedboolean

    Whether the resource is published.

    published_atstring

    Publication time, in ISO-8601 format.

    inventory_quantitynumber

    Inventory quantity.

    inventory_policystring

    Whether the product keeps selling when it is out of stock.

    inventory_trackingboolean

    Whether inventory tracking is enabled.

    cost_pricestring

    Cost price of the variant.

    vendorstring

    Vendor of the product.

    vendor_urlstring

    URL of the product vendor.

    barcodestring

    Barcode of the variant.

    mixed_wholesaleboolean

    Whether mixed wholesale is supported.

    tax_codestring
    retail_pricestring

    Retail price in the store's main currency unit.

    item_textstring
    disabledboolean
    is_free_giftboolean

    Whether the item is a free gift.

    custom_discountsundefined[]
  • ]
  • ineffectivesundefined[]

    Line items in the cart that can no longer be purchased.

    discount_applicationsundefined[]

    Discounts applied to this object.

    attributesundefined[]
    total_discountstring

    Total amount saved by all discounts on the cart.

    discount_line_item_pricestring

    Discounted total for the applied discounts.

    currencystring

    Currency of the cart, for example USD.

    original_line_pricestring

    Original price of the line item before discounts.

    original_total_pricestring

    Total price of the cart before any discounts.

    line_pricestring

    Combined price of all units in this line item, before discounts.

    total_pricestring

    Total price of the cart after discounts.

    notestring

    Note attached to the object.

    created_atstring

    Creation time, in ISO-8601 format.

    updated_atstring

    Last update time, in ISO-8601 format.

    item_countnumber

    Number of items in the cart.

    total_weightnumber

    Total weight of all items in the cart.

    invalid_msgstring
    identity_cart_idstring

    Identifier of the cart. Use it to link a cart to the order it becomes.

    user_idstring

Remove a line item from the cart

DELETE /{locale}/api/cart/{variant_id}

Use the DELETE /{locale}/api/cart/{variant_id} endpoint to remove a line item.

Example request

Example request
const data = {
id: "298422_d41d8cd98f00b204e9800998ecf8427e",
product_id: "588ed0ce-40af-44c7-8dea-afa18b489ef8",
variant_id: "83196e5a-b25f-42c3-8df5-359d83ea7ae8",
};

fetch(window.SHOPLAZZA.routes.root + '/api/cart/83196e5a-b25f-42c3-8df5-359d83ea7ae8', {
method: 'DELETE',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
})
.then((response) => response.json())
.then((data) => {
// do something...
})
.catch((error) => {
console.error('Error: ', error);
});

Request parameters

    variant_idstring

    ID of the variant. Send it in the path and in the request body.

    idstring

    ID of the line item to remove, taken from the id of a line item in the cart.

    product_idstring

    ID of the product.

Response

  • cart object
    line_itemsundefined[]

    List of line items.

    ineffectivesundefined[]

    Line items in the cart that can no longer be purchased.

    discount_applicationsundefined[]

    Discounts applied to this object.

    attributesundefined[]
    total_discountstring

    Total amount saved by all discounts on the cart.

    discount_line_item_pricestring

    Discounted total for the applied discounts.

    currencystring

    Currency of the cart, for example USD.

    original_line_pricestring

    Original price of the line item before discounts.

    original_total_pricestring

    Total price of the cart before any discounts.

    line_pricestring

    Combined price of all units in this line item, before discounts.

    total_pricestring

    Total price of the cart after discounts.

    notestring

    Note attached to the object.

    created_atstring

    Creation time, in ISO-8601 format.

    updated_atstring

    Last update time, in ISO-8601 format.

    item_countnumber

    Number of items in the cart.

    total_weightnumber

    Total weight of all items in the cart.

    invalid_msgstring
    identity_cart_idstring

    Identifier of the cart. Use it to link a cart to the order it becomes.

    user_idstring

Select which line items are checked out

POST /{locale}/api/cart/cart-select

Use the POST /{locale}/api/cart/cart-select endpoint to choose which line items of the cart are selected for checkout. Line items that are not in selected_cart_ids become unselected.

Example request

Example request
const data = {
selected_cart_ids: ["684765446766863303_d41d8cd98f00b204e9800998ecf8427e"]
};

fetch(window.SHOPLAZZA.routes.root + '/api/cart/cart-select', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
})
.then((response) => response.json())
.then((data) => {
// do something...
});

Request parameters

    selected_cart_idsstring[]

    The ids of the line items to select, as returned in id.

Response

  • cart object
    line_items object[]

    List of line items.

  • Array [
  • idstring

    ID of the line item.

    item_idstring
    product_idstring

    ID of the product.

    variant_idstring

    ID of the variant.

    quantitystring

    Quantity of the item.

    notestring

    Note attached to the line item.

    propertiesstring

    Custom properties captured on the line item.

    customboolean

    Whether the line item is a custom item.

    product_titlestring

    Title of the product.

    product_handlestring

    Handle of the product.

    product_urlstring

    Relative URL of the product page.

    variant_titlestring

    Title of the variant, for example Blue, Size M.

    product_typestring

    Product type.

    pricestring

    Price of a single unit of the line item.

    compare_at_pricestring

    Compare-at price of the item.

    origin_pricestring
    line_pricestring

    Combined price of all units in this line item, before discounts.

    original_line_pricenumber

    Original price of the line item before discounts.

    saved_pricenumber

    Amount saved on this line item.

    final_line_pricestring

    Combined price of all units in this line item, after line-level discounts.

    final_pricestring

    Price of a single unit of this line item, after line-level discounts.

    discount_applicationsundefined[]

    Discounts applied to this object.

    fixed_discount_totalstring
    discount_totalstring

    Total discount applied.

    discount_idstring

    ID of the discount applied.

    availableboolean

    Whether the item can be purchased.

    available_quantitynumber

    Quantity still available for purchase.

    can_buyboolean

    Whether the variant of the line item can be sold.

    weightstring

    Weight of the variant.

    weight_unitstring

    Unit of the weight, for example kg.

    skustring

    SKU of the variant, used for inventory tracking.

    spustring

    SPU of the product.

    requires_shippingboolean

    Whether shipping is required.

    taxableboolean

    Whether tax is charged.

    image object

    Image of the line item's variant.

    srcstring

    URL of the image.

    pathstring

    Path of the image file on the image server.

    widthnumber

    Width of the image, in pixels.

    heightnumber

    Height of the image, in pixels.

    altstring

    Alt text of the image.

    options object[]

    Option values of the line item's variant.

  • Array [
  • namestring

    Name of the product option, for example Color.

    valuestring

    Value selected for this product option.

  • ]
  • wholesale_price object[]

    Wholesale price tiers.

  • Array [
  • min_quantitynumber

    Minimum quantity required for this wholesale tier.

    pricestring

    Unit price of this wholesale tier.

  • ]
  • parts_pricestring
    product_tagsundefined[]

    Tags of the product.

    publishedboolean

    Whether the resource is published.

    published_atstring

    Publication time, in ISO-8601 format.

    inventory_quantitynumber

    Inventory quantity.

    inventory_policystring

    Whether the product keeps selling when it is out of stock.

    inventory_trackingboolean

    Whether inventory tracking is enabled.

    cost_pricestring

    Cost price of the variant.

    vendorstring

    Vendor of the product.

    vendor_urlstring

    URL of the product vendor.

    barcodestring

    Barcode of the variant.

    mixed_wholesaleboolean

    Whether mixed wholesale is supported.

    tax_codestring
    retail_pricestring

    Retail price in the store's main currency unit.

    item_textstring
    disabledboolean
    is_free_giftboolean

    Whether the item is a free gift.

    custom_discountsundefined[]
  • ]
  • ineffectivesundefined[]

    Line items in the cart that can no longer be purchased.

    discount_applicationsundefined[]

    Discounts applied to this object.

    attributesundefined[]
    total_discountstring

    Total amount saved by all discounts on the cart.

    discount_line_item_pricestring

    Discounted total for the applied discounts.

    currencystring

    Currency of the cart, for example USD.

    original_line_pricestring

    Original price of the line item before discounts.

    original_total_pricestring

    Total price of the cart before any discounts.

    line_pricestring

    Combined price of all units in this line item, before discounts.

    total_pricestring

    Total price of the cart after discounts.

    notestring

    Note attached to the object.

    created_atstring

    Creation time, in ISO-8601 format.

    updated_atstring

    Last update time, in ISO-8601 format.

    item_countnumber

    Number of items in the cart.

    total_weightnumber

    Total weight of all items in the cart.

    invalid_msgstring
    identity_cart_idstring

    Identifier of the cart. Use it to link a cart to the order it becomes.

    user_idstring

Save a note on the cart

POST /{locale}/api/cart/note

Use the POST /{locale}/api/cart/note endpoint to save a note on the cart. The body is application/x-www-form-urlencoded, not JSON.

Example request

Example request
const body = new URLSearchParams({ note: 'Leave the parcel at the door' });

fetch(window.SHOPLAZZA.routes.root + '/api/cart/note', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: body
})
.then((response) => response.json())
.then((data) => {
// do something...
});

Request parameters

    notestring

    The note to save on the cart.

Response

    statestring

    Request result flag; success or 0 means the request succeeded.

    messagestring

    Result message returned with the response.

    errorsundefined[]

    List of errors returned when the request fails.

    datastringnullable

    The response payload.

Get the number of items in the cart

GET /{locale}/api/cart/count

Use the GET /{locale}/api/cart/count endpoint to get cart count.

Example request

Example request
fetch(window.SHOPLAZZA.routes.root + '/api/cart/count')
.then((response) => response.json())
.then((data) => {
// do something...
})
.catch((error) => {
console.error('Error: ', error);
});

Response

    statestring

    Request result flag; success or 0 means the request succeeded.

    messagestring

    Result message returned with the response.

    errorsundefined[]

    List of errors returned when the request fails.

    data object

    The response payload.

    countnumber

    Number of items in the cart.