Attributes

Every attribute a page writes has one role, and each role has its twin in JavaScript. Values come from one object model: the objects next.query() returns and events carry, with the same snake_case field names.

RoleAttributesIn JavaScript
Objects: things with statedata-next-selector, data-next-option, data-next-checkout, data-next-promotionnext.query('selector.main')
Display: values into the pagedata-next-query, data-next-show, data-next-hide, data-next-each, data-next-for, data-next-i18nnext.query(), next.watch()
Actions: buttons and formsdata-next-actionnext.actions.<name>()
Inputsdata-next-fieldcheckout.* paths
Widgets: UI the SDK drawsdata-next-address, data-next-payment, data-next-express—

Every other attribute is a parameter of one of these, named after a field of the model: data-next-shipping-id="3" is shipping_id: 3, on an option and on an addItem button alike.

CODE
<span data-next-query="cart.total"></span>
CODE
await next.query('cart.total'); // 39
next.on('cart.calculated', (cart) => cart.total); // the same Cart

New here? Start with the Quickstart, a whole page to copy, then the Recipes: one task per page, each example tested against the SDK.

Pages built with the earlier attributes keep working: see Legacy attributes.

Setup

PageFor
Loader scriptdata-campaign, data-funnel: loading the SDK
URL parametersforcePackageId, forceBundleId, reset, debug, kept parameters
Page stateWhat the SDK sets for CSS: data-next-ready, data-next-selected, …
LanguagenextConfig.locale, nextConfig.translations: prices and texts

Objects

PageFor
CartThe cart and its lines
Selector and optiondata-next-selector, data-next-option: picks, order bumps, offers
Packagepackage.<id>: a package at the campaign's price
Checkoutdata-next-checkout and what the shopper entered
Order and upsellThe order on pages opened with ?ref_id
Promotiondata-next-promotion: tracked banners
Campaign and paramscampaign.*, param.<name>

Display

PageFor
data-next-queryWrites a value; data-next-format, data-next-empty
data-next-showShows on a condition
data-next-hideHides on a condition
data-next-eachOne copy of a template per item of a list
data-next-forThe object children read short paths from
data-next-i18nText or an attribute in the page's language

Actions

PageFor
data-next-actionRuns an action on click or submit; data-next-go
Action listEvery action, its arguments and its events

Inputs

PageFor
data-next-fieldCheckout fields, payment, variant pickers, line properties

Widgets

PageFor
data-next-addressAn address for the selected country
data-next-paymentThe payment methods the campaign offers
data-next-expressExpress buttons