Add an item to the cart

Adds `quantity` of a product variant to the caller's cart, creating the cart on first use. Adding a variant that is already in the cart INCREMENTS that single line rather than creating a second one, and the resulting quantity is clamped at the per-line cap instead of being rejected. The unit price and the product/variant labels are captured SERVER-SIDE from the catalogue at the moment of the add and are never read from the request; a later catalogue price change does not re-price an existing line. Totals are recomputed server-side on every mutation. A variant belonging to another site, to an unpublished product, or to a bookable product, an unknown variant, and a variant on a site whose product-variants slice is switched off all return the same 404. When this call creates a GUEST cart, the response carries `cartToken` once: it is the per-cart secret the client must send back in `X-Lynkow-Cart-Token` on every later guest cart call, and it is never returned again. Adding to a cart also SELF-HEALS it: any OTHER line whose variant has since stopped being sellable is auto-removed and reported in `removedLines`, so the returned total is always over sellable lines only. The just-added variant is checked for sale first, so it is never the pruned one. > **Note:** This endpoint requires the e-commerce feature to be enabled on your site.

POST/cart/lines
Base URLhttps://api.lynkow.com/storefront/{siteId}

Request body
required

  • quantity
    integer
    required

    Required. Between 1 and 999

  • variantId
    string
    required

    Required. Product variant identifier (var_ prefixed id)

Feedback

Was this page helpful?