Only one async basket operation can run at a time. Starting a second operation will throw. Use basketLoading to guard UI.
State
basketLoading
basketLoading is true while an async basket mutation runs. Disable buttons to prevent double submits.
orderItems
The list of items currently in the basket. Use it to render a mini cart, cart page, or order summary.
orderItems was called basketItems before release 109. The shape is the same. See Legacy (deprecated) below.
Example orderItems payload
formattedTotal
formattedTotal is a pre-formatted total string (e.g. "$29.00"). Use it for displaying the basket total in the UI without manual formatting.
expiresAt
UTC ISO timestamp of basket expiration. Baskets expire based on the original session — by default, two weeks after creation. Use it to block checkout on expired sessions.
Create or update a basket
initiateCheckout (new basket)
Use initiateCheckout when starting a fresh basket (no existing checkoutId). This is the entry point on pricing pages and offer cards — it creates a new basket on the server and returns the checkout ID.
Options:
You can pass either a single order item or an order object with multiple items:
Example — basic usage:
Example — multiple items (main offer + add-on):
Note: This method automatically:
Creates a new basket on the server
Sends add_to_cart analytics events
Sets tracking tags for the offer
addOfferToBasket (existing basket)
Use addOfferToBasket to add items to an existing basket (checkoutId already exists). Common for add-on selection and multi-item carts.
Example — adding an add-on linked to a parent offer:
Update or remove items
removeFromBasket
Remove an item from the basket by its ID. Used in cart item components and basket popovers to let users remove selections.
Example — cart item with a remove button:
swapOffer
Atomically replace one offer with another. Used for in-cart upsell and downgrade buttons — it removes the old item and adds the new offer in a single operation.
Example — upsell button inside a cart item:
Note: This method sends both remove_from_cart and add_to_cart analytics events and syncs the basket with the server.
updateItemQuantity
Update the quantity of an existing item. Used in quantity selectors on cart pages and floating cart dialogs.
Example — quantity control:
clearOrderItems
Remove all items from the basket. Used to reset state before significant changes, such as blocking a downgrade or starting a new selection flow.
Promotions
redeemPromoCode
Validate and apply a promo code to the basket. Returns the checkout ID on success.
Example — promo code input with error handling:
removePromoCode
Remove a previously applied promo code from the basket. The customer can then apply a different code or proceed without a discount.
Example:
Checkout
navigateToCheckout
Redirect to the checkout page. Typically called after adding items to the basket, often controlled by pageOptions.pushToCheckout.
Options:
Example:
Note: This method requires a valid basket ID to exist. If no basket has been initiated, it will throw an error.
setCheckoutDisabled
Gate checkout on a condition like terms acceptance. The checkout button remains disabled until setCheckoutDisabled(false) is called.
Example — terms acceptance gate:
Validation and metadata
validateBasket
Validate the basket against rules before proceeding to checkout. Currently supports "preventMixedRates" to block orders with mixed billing terms.
Example — prevent mixed billing terms at checkout:
updateCustomField
Set custom metadata on the order payload, passed downstream to billing systems like Zuora. Used in checkout custom field components and partner-specific integrations.
Example — collecting a company ID during checkout:
If you use Zuora, Limio maps custom fields to the Subscription object by default. Target other objects by suffixing the key:
Custom fields appear in the order payload under customFields:
updateBasketDetails
Update basket metadata such as billing address, customer details, or custom fields. Runs as a parallel operation — it won't block other basket mutations.
Example — pre-filling customer and billing details:
Subscription update checkouts
For subscription update (change plan) flows, see the dedicated Subscription Update Checkout page. It covers starting an update checkout with initiateCheckout using order_type: "update_subscription", selecting offers with selectOfferForSubscriptionUpdate, and how updateItemQuantity behaves differently in update checkouts.
Cart persistence and authentication
For the basket to persist across multiple pages, anonymous authentication (light auth) or full authentication must be enabled on each page in the Page Builder. Without this, navigating between pages clears the basket.
If authentication is set to None on a page, the basket state will not persist when navigating away. Set authentication to Anonymous Auth (light auth) on every page that should share a basket.
After changing authentication settings on a page, you must rebuild and republish the page. Use an incognito window or hard refresh to verify the change has taken effect. The basket is stored server-side and keyed to the session.
Notes for production UI
Guard every mutation with basketLoading.
Use parentId when adding add-ons linked to a main offer.
Use validateBasket("preventMixedRates") before checkout if your catalog has offers with different billing terms.
Legacy (deprecated)
The methods below are deprecated. They still work for backward compatibility, but new components should use the modern replacements listed for each.
addToBasket
Replaced by:initiateCheckout (new baskets) or addOfferToBasket (existing baskets).
addToBasket creates or updates the basket in a single call. It does not give you control over whether the basket is new or existing — the newer APIs split this into two explicit steps.
Options:
Field
Type
Description
quantity
number
Item quantity (default: 1)
parentId
string
Links an add-on to a parent offer
orderItemActionType
"add" | "remove" | "update"
Action type for subscription update checkouts
Example — basic usage:
Example — adding an add-on linked to a parent:
goToCheckout
Replaced by:navigateToCheckout.
goToCheckout optionally initiates or updates the basket before navigating. The newer navigateToCheckout only handles navigation — basket creation is handled separately via initiateCheckout.
Example — with journey configuration:
basketItems
Replaced by:orderItems.
basketItems is a legacy alias for orderItems, kept for backward compatibility. The data shape is identical.