novinzodevelopers
Storefront & themes

Storefront API

Use same-origin JSON routes, plugin endpoints, hosted web components, and Liquid themes on a store domain.

Each store serves pages and a JSON API on its own domain. The domain is a Novinzo subdomain or a seller custom domain.

Browser code uses relative URLs, such as fetch("/api/cart/synchronize", ...). It does not need a private SDK or direct backend /rpc access.

The storefront forwards the required domain and shopper cookies to the backend. Store identity comes from the domain.

A store's theme can be deployed from the seller's GitHub repository on every push. See Deploying a theme.

Conventions

API routes use POST with JSON bodies. Page and asset routes use GET, while plugin public routes support additional methods.

Use the linked contract schemas for exact payload and response fields. Nullable fields require null, while optional keys can be omitted when their schema permits omission.

Money uses integer minor units and a currency code. Dates use ISO 8601 strings.

Every route resolves the store from the domain. A route that accepts storeId ignores it: the field remains for older platform versions and does not choose the store.

Errors

The API reports errors in this envelope:

{
  "error": {
    "message": "A cart line holds at most 10000 units",
    "code": "VALIDATION_ERROR"
  }
}
StatusExample codesMeaning
400VALIDATION_ERROR, STOREFRONT_ERROR, STORE_UNRESOLVED, checkout error codesAn invalid payload or refused operation, or a host that names no store.
401InvalidCredentialsError, CustomerOtpExpiredError, CustomerSessionMissingErrorInvalid shopper credentials, an expired sign-in code (request a new one), or a missing session.
404SESSION_NOT_FOUND, STORE_NOT_FOUND, PREPARED_CHECKOUT_NOT_FOUNDAn unknown resource, store, or prepared checkout.
429RATE_LIMITED, CustomerAuthRateLimitedErrorA request limit. Respect Retry-After when present.
500INTERNAL_ERROR, STORE_LOOKUP_FAILEDAn unexpected failure, or the store lookup failed.
503UNAVAILABLEThe backend is temporarily unavailable. Try again shortly.
504TIMEOUTA backend request that did not finish in time.

Customer authentication and order routes use backend error tags as codes. Checkout errors use uppercase codes.

An unfinished payment can also produce paymentStatus. This field describes payment progress, including pending or underpaid crypto invoices.

Rate limits

Limits use fixed 60-second windows. Most zones count requests per client IP and store domain.

ZoneRoutesRequests per minute
PagesRendered HTML60
Checkout initiation/api/checkout/initiate, /api/checkout/initiate-prepared and /api/checkout/initiate-renewal10
CartOther checkout routes, cart, payment methods, availability, orders, and plugin routes60
AuthenticationEach /api/auth/* route, per client IP10

Limit responses use status 429, a Retry-After header, and Cache-Control: no-store.

Cart, catalog and payment methods

RoutePayloadResultContract
/api/cart/synchronizecart.itemsCurrent prices and availability, without unavailable lines.StorefrontSynchronizeCart
/api/payment-methods{}Enabled payment methods.StorefrontListPaymentMethods
/api/payment-methods/surchargesamount the buyer owes once discountedWhat each payment method adds; connectionId is the method's id.StorefrontQuotePaymentSurcharges
/api/products/availabilityproductIdVariant availability as in_stock, low_stock, or sold_out, never a count.StorefrontGetVariantAvailability

A cart has at most 50 lines and 10,000 units per line. A variant's minimum and maximum quantity per order apply within that ceiling: a line below the minimum is raised to it when the cart is priced, and the quantity controls stop at both. Each line keeps its original price beside the current price.

The cart lives in the browser. After synchronization, show changed prices and unavailable lines before payment.

Availability responses use Cache-Control: no-store.

Checkout

RoutePayloadResultContract
/api/checkout/initiateItems, email, payment provider, and optional attempt identifier.Session, order, payment intent, and validated cart.CheckoutInitiate
/api/checkout/initiate-preparedPrepared checkout identifier and buyer fields, not items or a discount plan.Session, order, payment intent, and validated cart.CheckoutInitiatePrepared
/api/checkout/preparedpreparedCheckoutIdPrepared status, cart, expiration, and return URLs.StorefrontGetPreparedCheckout
/api/checkout/change-payment-methodcheckoutSessionId, newProviderId, cryptoAsset, and optional newConnectionId.A new payment intent and the cart priced for the new method.CheckoutChangePaymentMethod
/api/checkout/completecheckoutSessionId and processorData.Order identifier, status, and total.CheckoutComplete
/api/checkout/cancelcheckoutSessionId{"success":true}.CheckoutCancel

A checkout session identifier grants access to that payment session. Do not log or share it.

A prepared checkout is an unpaid checkout with fixed source lines. A seller or authorized plugin creates it through PreparedCheckoutCreate.

Send the buyer to the returned store URL, /checkout/<preparedCheckoutId>. The pay page reads the current prices and supports the stored return URLs.

Prepared checkout statuses are open, expired, completed, in_progress, and unavailable. A pending payment can finish after expiration, so expiration alone does not prove payment failure.

Subscription renewals

A subscription renewal waiting for the buyer to pay it has its own pay page, /subscriptions/renew/<renewalId>?token=<token>. The link's token is signed, so only the link opens the renewal. /api/subscriptions returns it as openRenewal.path for a renewal waiting to be paid.

RoutePayloadResult
/api/checkout/renewalrenewalId and token from the link.The renewal's status (open, in_progress, paid or closed), terms, dueAt, payableUntil, customerEmail and cart.
/api/checkout/initiate-renewalrenewalId, token, and the payment choice: providerId, connectionId, billingAddress and cryptoAsset.Session, order, payment intent, and validated cart, as /api/checkout/initiate returns them.

The renewal's lines and their prices come from the subscription, locked when the buyer subscribed, never from the browser. A link that opens no renewal of the store answers 404 with the code RENEWAL_NOT_FOUND. Continue from the payment intent as for any checkout.

Checkout flow

List payment methods

Send POST /api/payment-methods with {}. Show the enabled methods and retain the selected provider identifier.

Refresh the cart

Send POST /api/cart/synchronize with the browser cart. Show price changes and removed lines before the shopper pays.

Show payment method surcharges

Send POST /api/payment-methods/surcharges with the amount the shopper owes for the goods, in the store's currency: the subtotal with the plan's charge lines added and its discounts taken off. Show each method's surcharges beside it, and ask again when that amount changes.

The quote is for display only. Checkout prices the chosen method again when it starts, and refuses with INTERNAL_ERROR when a surcharge plugin cannot price it; the shopper can try again shortly.

Show shipping and tax

Send POST /api/checkout/price-lines with the cart's items (each a variantId and quantity), the same amount, surcharges: the sum of what the picked method was quoted, as one money value (zero when it adds nothing), and destination: the shipping address's country and postalCode when a line ships, else the buyer's billing country with a null postalCode, or null while neither is known.

The answer has quote and buyerCountry, the country the request came from, or null. A Quoted quote lists lines, each with a type of shipping, tax or included_tax, a description and an amount; included_tax is already inside the prices. A DestinationNotShipped quote means that no app the store installed ships there. Both carry taxed: whether an app works out the store's tax. A cart with a line that ships and no destination is refused.

This quote is for display only too. Checkout asks the store's apps again for the cart it charges.

Initiate the checkout

Send this JSON body to POST /api/checkout/initiate. Replace the example UUIDs with the variant and purchase attempt identifiers.

{
  "attemptId": "b0c4e7d2-c027-471b-8186-b4ed6fb8ed88",
  "items": [{ "variantId": "0d9a51b3-0987-4dc0-a5d1-f8e5d611fd05", "quantity": 1 }],
  "email": "buyer@example.com",
  "providerId": null,
  "billingAddress": null,
  "priceAdjustmentPlan": null,
  "cryptoAsset": null
}

An attempt identifier names one purchase attempt. Reuse it after a lost response to recover the same session instead of creating another payment.

If the payload changes, use a new attempt identifier. Reusing an identifier with different purchase data produces ATTEMPT_CONFLICT.

Items must contain one to 50 unique variants. providerId: null selects the store default payment provider.

To charge the method the buyer picked, also send connectionId: that method's id from /api/payment-methods. It takes precedence over providerId, and only it tells apart two methods of one provider, such as two plugins' methods, which are both plugin. The payment intent returns the connectionId it charges through.

A line that /api/cart/synchronize returns with requiresShipping: true is sent to the buyer's address. When the cart has one, also send shippingAddress, with name, line1, city and the two-letter country code, and optionally line2, region, postalCode and phone. A Portuguese address needs a valid postalCode, such as 1100-148. Without the address, checkout refuses with SHIPPING_ADDRESS_REQUIRED, and with DESTINATION_NOT_SHIPPED when no app the store installed ships to that address. A cart without a shipped line ignores the field.

A line returned with recurrence (intervalUnit and intervalCount) is sold only as a subscription. When the cart has one, show the buyer the terms and send what they agreed to in subscriptionConsent: one entry per interval, in the order each interval first appears among the lines, each with its interval (unit and count) and its renewalTotal, the undiscounted sum of those lines' unit prices times their quantities. A cart with a recurring line and no subscriptionConsent is refused with INVALID_CART, and with SUBSCRIPTION_TERMS_CHANGED when the terms are no longer the cart's, such as after a price change. Show the current terms and ask again. For a cart of one-off lines, leave the field out or send [].

A signed priceAdjustmentPlan applies plugin discounts and charge lines. On the checkout page, a plugin's storefront block hands its plan to nz-checkout-form with the nz:price-adjustment-plan event. If it becomes stale, get a new plan before another purchase attempt.

For a prepared checkout, call /api/checkout/initiate-prepared with preparedCheckoutId and the buyer fields, including shippingAddress and subscriptionConsent as above. Do not send items or a price adjustment plan.

The returned cart's adjustments list each discount and charge line and the chosen method's surcharges, with type, description and amount, taking subtotal to total.

Hand off to the payment provider

The payment intent identifies the next action:

ProviderBrowser action
stripeUse its public client library with the publishable key and client secret.
paypalDraw PayPal's buttons with clientMetadata.sdkUrl and clientId for the order in the client secret, or navigate to redirectUrl.
nmiRender the card fields with Collect.js from clientMetadata.collectJsUrl and tokenizationKey, and send its token as processorData.paymentToken when you complete.
revolutWith clientMetadata.embeddedCheckout, draw Revolut's widget from its embedJsUrl and publicKey for the order in the client secret. Without it, navigate to redirectUrl.
A provider with redirectUrlNavigate to the returned URL.
cashappShow paymentInstructions and collect the buyer's transaction ID.
cryptoShow cryptoDetails and the available assets in clientMetadata.assets.
rewarbleCollect the voucher codes required by that provider.
noneContinue without a browser payment action.

Use /api/checkout/change-payment-method to switch providers. Send the picked method's id as newConnectionId, which takes precedence over newProviderId as connectionId does when a checkout starts. Continue with the new payment intent that it returns, and show its cart: the order's discounts plus the new method's surcharges and the tax quoted again on them, so the total can change.

Complete the checkout

Send /api/checkout/complete with the session identifier and processorData. Use null when the provider requires no browser result.

Completion is idempotent, which means that repeated completion returns the same order. For delayed payments, poll this route and use the returned paymentStatus.

For cashapp, send the transaction ID as processorData.transactionId, with an optional notes. The seller confirms that payment by hand, so the route answers PAYMENT_FAILED with paymentStatus: "pending" until they do. After that, poll with processorData: null.

Show the order

Send an ordinary cart shopper to /orders/<orderId>?checkout=<checkoutSessionId>. The page grants guest access through that checkout session.

For a prepared checkout, use its stored success URL after completion. The platform replaces {CHECKOUT_SESSION_ID} with the session that paid.

If the shopper abandons a payment, call /api/checkout/cancel. A failed cancellation is not proof that the payment stopped.

Checkout error codes

The reference lists the errors for each operation. CheckoutError has these codes:

INVALID_CART EMPTY_CART OUT_OF_STOCK QUANTITY_OUT_OF_RANGE
PAYMENT_PROVIDER_ERROR PAYMENT_FAILED SESSION_NOT_FOUND SESSION_EXPIRED
SESSION_ALREADY_COMPLETED PAYMENT_IN_PROGRESS ATTEMPT_CONFLICT
PRICE_ADJUSTMENTS_OUTDATED SUBSCRIPTION_TERMS_CHANGED CHECKOUT_REFUSED
SHIPPING_ADDRESS_REQUIRED DESTINATION_NOT_SHIPPED INTERNAL_ERROR

PAYMENT_IN_PROGRESS means another checkout session for the same prepared checkout can still be paid, so a second one cannot start.

CHECKOUT_REFUSED means an app the store installed refused the checkout, such as one that blocks the buyer's region, or that too many cards were declined for the order and the buyer must pick another payment method. Its message is written for the buyer: the app's, or Novinzo's for declined cards.

A link can open the store's checkout for one variant, without the shopper's cart:

/checkout?variant=<variant id>&quantity=<units>[&email=<address>]

The checkout page's nz-checkout-form reads the query. Following the link does not change the shopper's cart, and the page prices and charges only the named line.

ParameterRule
variantRequired. A variant UUID. Its presence makes the page treat the URL as a checkout link.
quantityRequired. Decimal digits only, from 1 to 10,000 units. Forms such as 1e2, 0x10 and 5.0 are refused.
emailOptional. Prefills the contact field when it is a valid address of at most 254 characters. The buyer can change it.

A link with a missing or invalid variant or quantity is refused rather than corrected, before any request. The page shows "This checkout link isn't valid."

The store prices the line as it prices a cart line. A variant that this store does not sell, or no longer offers, shows "This item is not available." Checkout also applies the variant's own quantity limits.

The buyer sees the quantity but cannot change it. Coupons still apply.

Build the link on the store's domain, such as https://<store domain>/checkout?variant=0d9a51b3-0987-4dc0-a5d1-f8e5d611fd05&quantity=1. Encode email as a query value.

Buy Now checkouts

The product page's Buy Now control, described under product actions, checks out one variant without the cart. It stores that line in the tab's session storage and opens /checkout?buy-now.

That URL only works in the tab that chose Buy Now. In a new tab, on another device, or after the browser refused the write, the page shows "We couldn't find the item for this Buy Now checkout." The shopper's cart is unchanged.

A prepared checkout path, /checkout/<preparedCheckoutId>, takes precedence over the query. A checkout link takes precedence over ?buy-now, which takes precedence over the cart.

Customer accounts and orders

Shoppers sign in with a code sent by email. Same-origin requests carry the store customer cookie automatically.

RoutePayload or resultContract
/api/auth/otp-requestEmail. Returns {"status":"sent"}.CustomerOtpRequest
/api/auth/otp-verifyEmail and six-digit code. Returns the customer and sets the session cookie.CustomerOtpVerify
/api/auth/logoutEnds the customer session.CustomerLogout
/api/orderspage, pageSize, sort, and filters.StorefrontListOrders
/api/orders/getorderId.StorefrontGetOrder
/api/orders/invoiceorderId. Returns downloadUrl and expiresAt.StorefrontDownloadInvoice
/api/store-creditReturns buyer: the signed-in shopper's email, store credit balance and the method that pays with it; null for a guest.StorefrontStoreCredit
/api/subscriptionsReturns the signed-in shopper's subscriptions, newest first, each with its locked items, renewalTotal, interval, currentPeriodEnd and the openRenewal pay path.StorefrontListSubscriptions
/api/subscriptions/cancelsubscriptionId. Ends a live subscription at the end of its paid period, a past-due one at once; nothing is refunded. Returns the subscription.StorefrontCancelSubscription

Guest access links use an access query parameter on the order URL. Order details include delivered keys when a plugin supplies them.

The signed-in shopper's subscriptions have their own pages: /subscriptions lists them and /subscriptions/<subscriptionId> shows one. A theme renders them from templates/subscriptions.liquid and templates/subscription-detail.liquid with nz-subscriptions and nz-subscription-detail; see Subscription pages.

Plugin public routes

The store forwards /plugins/<code>/storefront-public/<path> to the installed plugin at /storefront-public/<path>. A path outside /storefront-public returns 404.

It resolves the store from the domain and attaches the store header and invocation token. An unknown or uninstalled plugin produces 404.

Forwarded request headers are accept, authorization, content-type, and idempotency-key. The proxy does not forward shopper cookies.

The proxy rejects plugin redirects with 502. It strips response cookies, transport security headers, and plugin CORS headers.

Responses also pass media-type restrictions and receive X-Content-Type-Options: nosniff. Serve API data as JSON, not executable HTML.

Plugin requests use the cart rate limit. Read Plugins on the storefront for route, order-viewer, and response details.

An API access credential reaches the plugin through Authorization: Bearer .... The credential guide defines its scope and failure behavior.

Assets

RouteContent
/theme/assets/*Assets from the active theme.
/plugins/<code>/assets/*Static assets from an installed plugin.
/components/* and /lib/*Hosted storefront component bundles.

Plugin assets require a recognized store domain and current installation. The Worker receives no store header or invocation token for asset requests.

The proxy forwards only documented caching and range headers. It permits credential-free asset redirects and applies static media-type restrictions.

Web components

A web component is a browser custom element with built-in behavior. Novinzo hosts these elements on the store domain, so themes do not install private UI packages.

ElementPurposeAttributes
nz-checkout-formPayment selection and checkout completion.store-id, currency
nz-cart-drawerBrowser cart drawer.store-id, surface (light draws the drawer light, for a theme on a light page; it is dark otherwise)
nz-cart-counterUnits in the browser cart, kept current as it changes.count (shown until the cart is read), max (default 99, larger counts show 99+), hidden-when-empty
nz-login-formEmail code sign-in.store-name, store-logo-url, redirect-to, privacy-href, terms-href
nz-orders-listCustomer order list.store-name, store-logo-url
nz-order-detailOrder details and invoice download.order-id, store-name, store-logo-url
nz-subscriptionsThe signed-in shopper's subscriptions.store-name, store-logo-url
nz-subscription-detailOne subscription, with paying its open renewal and cancelling it.subscription-id, store-name, store-logo-url
nz-image-carouselProduct image carousel.images (the product's images as JSON, such as {{ product.images | json }}), fallback-alt
<nz-checkout-form
  store-id="{{ store.id }}"
  currency="{{ store.currencyIsoCode }}"
  data-island="nz-checkout-form"
  data-hydrate="eager"
></nz-checkout-form>

nz-checkout-form shows what the template writes inside it, such as a plugin's {% plugin_block %} that asks the buyer something, in its card after its own fields, and disables those controls while a payment is under way.

The storefront discovers theme elements and adds their hosted scripts. data-hydrate accepts eager, visible, idle, or none.

nz-login-form links a policy below the sign-in card only when it receives that policy's privacy-href or terms-href. A policy page exists only after the store publishes it, so pass each one conditionally, for example {% if store.privacyPolicy != blank %}privacy-href="/privacy"{% endif %}.

A fetched plugin block must load its own script from /plugins/<code>/assets/. Automatic discovery does not cover those snippets.

Other elements

ElementPurposeAttributes
error-pageThe store's 404, error and checkout-cancel card.store-name, store-logo-url, error-title, message, error-code, tone, action-label, action-href, support-email
nz-persistent-counterA plus/minus counter whose value persists in session storage across page navigation.counter-id, initial, min, max, step

error-page shows error-code as its heading and error-title beneath it. tone="pending" shows a payment that is still being confirmed, with a spinner and no button. tone="failed" shows a payment that did not go through.

Both tones lead with the title, hide the code and leave out the red error styling. Any other tone value is read as an error.

action-label and action-href add a main button. On a failed payment, support-email adds a Contact seller button. Without it, and on every error page, a button leads back to the store.

nz-persistent-counter keeps one value per counter-id for the browser session. It dispatches a bubbling counter-change event with { value, oldValue, counterId } when the value changes.

Styling the platform's pages

nz-checkout-form, nz-login-form, nz-orders-list, nz-order-detail, nz-subscriptions, nz-subscription-detail and error-page draw the pages a theme does not: sign-in, checkout, a buyer's orders and subscriptions, and the error pages. They draw themselves the same on every theme, light with dark text.

To give them your theme's look, set these custom properties in your stylesheet. One you leave out keeps its default.

PropertyWhat it setsDefault
--nz-pageThe page behind the cards.#fafafa
--nz-surfaceCards, and the tiles a buyer picks one of, such as payment methods.#fff
--nz-fieldText fields, and the track of a row of tabs.#f7f7f7
--nz-inkText. Quieter text, hairlines and soft fills are tints of it.black
--nz-accentThe main button.#111113
--nz-on-accentThe text on the main button.#fff
--nz-focusThe ring around the field in use and around the picked tile.blue
--nz-roundnessA number the corner radii are multiplied by. 0 squares the corners.1

The pages are set in your theme's --font-sans, and their amounts and codes in its --font-mono.

assets/input.css
:root {
  --nz-page: #f4efe6;
  --nz-accent: #a42325;
  --nz-roundness: 0;
}

The page around each element is your layout's. The starter's layouts/novinzo.liquid paints it #fafafa, so a theme that changes --nz-page gives that layout's html the same colour. The pages' icons are dark: keep --nz-page and --nz-surface light and --nz-ink dark.

For what a property cannot say, such as capitals on a button or a border in place of a card's shadow, style the parts the pages share. Each carries a data-nz-part attribute:

PartWhat it is
buttonA button. Its data-variant is primary for the main button and secondary for a quieter one; the dark cart drawer's two are white and dark.
cardA card.
headingA card's heading.
fieldA text field or a select.
tabsA row of tabs. Each tab in it is [role="tab"], and the chosen one [aria-selected="true"].
tileOne of several choices, such as a payment method.
assets/input.css
nz-checkout-form [data-nz-part="button"] {
  border-radius: 999px;
  text-transform: uppercase;
}

The elements' own styles are in cascade layers, so a rule of yours outside any @layer replaces them whatever its specificity. The cart drawer's buttons are the same button part. On the light drawer, the checkout button is the main button and reads --nz-accent and --nz-on-accent too. The dark drawer's buttons keep their own colours.

Browser events and product actions

nz-cart-drawer owns the browser cart. Theme code reaches it through window events and data attributes, so it never imports the drawer's code. These features work on pages whose layout includes nz-cart-drawer.

Window events

EventDirectiondetail
nz:cart-addTheme dispatchesOne variant to add, described below. The drawer adds it and opens.
nz:cart-openTheme dispatchesNone. The drawer opens.
nz:cart-changedStorefront dispatchesNone. The stored cart changed in this tab. Read the cart again if you show it.
nz:checkout-cart-pricedStorefront dispatchesThe cart nz-checkout-form pays for, each time the server prices it. A plugin block signs its plan for this cart.
nz:checkout-startingStorefront dispatchesThe buyer pressed Pay. detail.waitUntil(promise) has nz-checkout-form wait for a plugin block to hand over its plan before the checkout starts.
nz:price-adjustment-planPlugin block dispatchesThe signed plan for nz-checkout-form to pay with. See Handing the plan to checkout.
nz:price-adjustment-plan-appliedStorefront dispatchesThe plan nz-checkout-form now pays with, or null once a cart edit dropped it.

Dispatch the events on window:

assets/add-to-cart.js
window.dispatchEvent(
  new CustomEvent("nz:cart-add", {
    detail: {
      variantId: "0d9a51b3-0987-4dc0-a5d1-f8e5d611fd05",
      productName: "Pro license",
      variantName: "30 days",
      pricePerUnit: { amountMinorUnits: "1500", currency: "USD" },
      imageUrl: "",
    },
  }),
);

window.dispatchEvent(new CustomEvent("nz:cart-open"));

The nz:cart-add detail needs every field but quantity:

FieldType
variantIdVariant UUID.
productName, variantNameStrings shown in the cart. variantName can be empty.
pricePerUnit.amountMinorUnitsThe unit price in minor units, as a string of digits.
pricePerUnit.currencyThe store's ISO 4217 currency code, such as USD.
imageUrlImage URL string, or an empty string.
quantityOptional. The units to add, a whole number above zero, such as a volume discount's tier. One when left out.

A detail that does not decode adds nothing; the drawer still opens. The price is the one the shopper saw. The drawer has the server price the cart when it opens, and checkout always charges current prices.

Adding a variant already in the cart adds the detail's quantity, or one unit. A new line starts at that many units and is raised to the variant's minimum quantity when the drawer prices the cart. A cart that already holds 50 different variants refuses a new one and says why.

Product actions

Inside a container marked data-product-actions, the drawer handles clicks on these controls, whatever element carries the attribute:

AttributeEffect
data-add-to-cartAdds the selected variant to the cart and opens the drawer.
data-buy-nowChecks out the selected variant alone through /checkout?buy-now, leaving the cart untouched.
data-cart-openOpens the drawer. It also works outside a product container, such as on a header cart button.

The drawer cancels the click's default action, so a link or submit button does not also navigate.

The container and each variant chip describe what to add:

<div
  data-product-actions
  data-product-id="{{ product.id }}"
  data-product-name="{{ product.name }}"
  data-currency="{{ store.currencyIsoCode }}"
  data-image-url="{{ product.images.first.url }}"
>
  {% for variant in product.variants %}
    <label
      data-variant-id="{{ variant.id }}"
      data-variant-name="{{ variant.name }}"
      data-price-minor-units="{{ variant.unitPrice | money_minor_units }}"
    >
      <input type="radio" name="variant-{{ product.id }}" value="{{ variant.id }}" {% if forloop.first %}checked{% endif %}>
      {{ variant.name }}
    </label>
  {% endfor %}
  <button type="button" data-buy-now>Buy Now</button>
  <button type="button" data-add-to-cart>Add to Cart</button>
</div>

The selected variant is the chip whose radio is checked, or the first chip. Each chip needs data-variant-id and data-price-minor-units, and the container needs data-product-name and data-currency. data-variant-name and data-image-url are optional.

On each page view, the drawer requests live availability for data-product-id from /api/products/availability. It sets data-availability on each chip to in_stock, low_stock or sold_out.

A chip that the answer does not name, or a lookup that fails or takes longer than eight seconds, is marked unconfirmed. A container without data-product-id marks every chip unconfirmed.

While the selected variant is sold_out or unconfirmed, the drawer disables the data-add-to-cart and data-buy-now buttons and ignores their clicks. If the page's default selection is sold out, the drawer selects the first variant in stock instead.

Styling the drawer

The drawer draws itself, dark by default. surface="light" draws it light, so its text, controls and buttons stay readable on a theme whose pages are light:

<nz-cart-drawer store-id="{{ store.id }}" surface="light"></nz-cart-drawer>

To change its shape, type or spacing, style its parts from your stylesheet. Each carries a data-cart-part attribute:

PartWhat it is
backdropThe layer that dims the page behind the open drawer.
panelThe drawer itself.
header, titleThe row at the top, and the "Your cart" title in it.
bodyThe list of lines.
lineOne line of the cart.
line-image, line-title, line-variantThe line's picture, its product name and its variant name.
line-quantity, line-priceThe row holding the line's quantity stepper, and the column with its amount and its remove button.
emptyWhat shows in place of the lines: that the cart is empty, or that it could not be loaded.
footer, totalsThe block at the bottom, and the subtotal rows above its button.
assets/input.css
nz-cart-drawer [data-cart-part="panel"] {
  inset: 0 0 0 auto;
  width: min(480px, 100vw);
  border-radius: 0;
}

The drawer's own styles are in the utilities cascade layer, so a rule of yours outside any @layer replaces them whatever its specificity. The close button is [data-cart-close], and a line's amounts are [data-line-total] and [data-line-unit-price].

On this page