SubblySubbly
Log inGet started
  • Get started
  • Developer resources
SubblyCart.js widget reference
Docs
Information
    GlobalsCookies and storageErrors
Methods
    Open the widgetClose the widgetToggle the widgetLoad the shopUpdate the cartConfigure an itemAdd an itemUpdate an itemRemove an itemApply a couponQueue a couponRemove the couponApply a gift cardRemove the gift cardSet the languageSet the currencyReset the cartChange the settingsConfigure a giftPrefill customer dataSign a customer inSign the customer outReload the cartChange the URL configDisable the widgetEnable the widgetInitialize manually
Properties
    CartShopStateSDK clientEvent emitter
Events
    Listen to eventsStop listeningCart readyCart updatedWidget openedWidget closedCart resetEmail collectedPurchase completedCustomer signed inCustomer signed upCustomer signed out
Settings
    Configuration keysSettings keysURL parameters
Theming
    CSS variablesBase tokens

SubblyCart.js widget

SubblyCart.js is Subbly's cart and checkout widget. One script tag adds a cart, a product configurator and a full checkout to any website, in your shop's colours and languages. It talks to the Storefront API through Subbly.js, and it keeps the cart ID and the customer's access token in cookies, so a cart survives a page load.

Load

Embed the widget
<script> window.subblyConfig = { apiKey: 'YOUR_STOREFRONT_API_KEY' } </script> <script type="module" src="https://assets.subbly.co/cart/cart-widget.js"></script>

The widget reads window.subblyConfig the moment it runs, so write the config object first. Every method and property in this reference belongs to window.subblyCart, set once the subbly-cart-initialized event has fired on window.

Globals

GlobalWhat it is
window.subblyConfigThe config object you write, read once while the widget loads.
window.SubblyCartThe widget class. Call SubblyCart.initialize(config) on it when you set init: false.
window.subblyCartThe initialized widget instance — the object every method and property in this reference belongs to. globalName renames it.
window.subblyCheckoutOptional. The item to configure in standalone checkout mode: an object with a payload key holding a ConfigureItemPayload, or null.

Cookies and storage

KeyStoreWhat it holds
subbly_cart_idcookie, path /, 365 daysID of the active cart.
subbly_access_tokencookie, path /, 365 daysAccess token of the signed-in customer.
referral_idcookie, 30 daysReferral ID from the r query parameter, kept for the next visit.
subbly_checkout_payloadlocalStorageThe item to configure in standalone checkout mode, tied to one shop and cart.

Errors

The widget throws a plain Error with a readable message — The cart is not initialized, for example. Calls that reach the API reject with the Subbly.js error object, which carries a code: not_found, bad_request, out_of_stock, payment_requires_action, user_email_is_not_unique or unauthenticated.

Handle a failure
try { await subblyCart.applyCoupon('WELCOME10') } catch (err) { console.warn(err.code ?? err.message) }

To install the widget, wait for it, and set every key of window.subblyConfig, see the Cart widget article.

Last modified on September 12, 2026
Javascript