Selector and option

data-next-selector is a group of data-next-options, one picked. An option on its own is an order bump: a click puts it in the cart, the next takes it out. On a page opened with ?ref_id both are post-purchase offers, priced for the order and added with acceptUpsell.

CODE
<div data-next-selector="main">
  <div data-next-option="one" data-next-items="1">…</div>
  <div data-next-option="three" data-next-items="1x3" data-next-vouchers="TRIO10" data-next-selected>
    <span data-next-query="price"></span> each
    <s data-next-show="total_discount > 0" data-next-query="subtotal"></s>
  </div>
</div>

<div data-next-option="protect" data-next-items="9">Add protection for <span data-next-query="total"></span></div>

Inside an option, short paths read that option (total, price, lines.0.image); anywhere else, selector.main.total reads the picked one and selector.main.options.three.total a given one. An order bump reads as selector.<its id>.

Attributes

AttributeOnMeans
data-next-selector="<id>"a containerThe selector. Its options are the [data-next-option] inside it
data-next-deferselectorThe pick is only remembered; nothing goes in the cart until an addItem button names the selector
data-next-option="<id>"optionOne option. The id names it in events, ?forceBundleId and selector.<id>.options.<id>
data-next-items="1x3, 5"optionIts lines: package id, then x and the quantity (1 when left out), comma-separated
data-next-selectedoptionPicked first. ="false" reads as not set
data-next-vouchers="CODE, CODE"optionCodes applied with its lines and used when it is priced
data-next-shipping-id="<id>"optionThe shipping method set when it goes in the cart
data-next-quantityoptionHow many times its lines are taken. Default 1
data-next-min-quantity, data-next-max-quantityoptionLimits for setQuantity. Default 1 and 999
data-next-slotsoptionEach unit is a slot that can be its own variant; draw them with data-next-each="slots"

The first pick is ?forceBundleId, else the option already in the cart, else data-next-selected, else the first. Each option is priced on the server with its own vouchers; until that price arrives, the campaign's prices show (an offer shows nothing until it is priced).

An order bump takes one package (data-next-items="9" or "9x2").

Set by the SDK

On an optionWhen
data-next-selected, aria-pressedIt is the picked one (a bump: on)
data-next-in-cartIts lines are in the cart
data-next-loadingThe options are being priced

The 0.4.x classes (next-selected, next-active, next-in-cart, next-not-in-cart) are set too, for CSS that already selects them.

Fields

FieldTypePresent
pricenumberpricedtotal ÷ quantity: one package, after discounts.
original_pricenumberpricedsubtotal ÷ quantity: one package, before discounts.
subtotalnumberpricedWhat it costs before discounts.
total_discountnumberpricedsubtotal − total.
discount_percentagenumberpricedtotal_discount ÷ subtotal × 100, to two decimals.
selector_idstringalwaysdata-next-selector-id, or toggle:<package_id> for a toggle.
type"bundle" | "offer" | "toggle"always
option_idstringoptionalThe picked option's data-next-bundle-id; none for a toggle.
linesCartItem[]alwaysThe lines the picked option puts in the cart, at its quantity; the toggle's line for a toggle. Priced once the option has a price.
currencystringcampaignISO 4217, such as USD.
totalnumberpricedWhat the picked option costs after discounts.
quantitynumberalwaysPackages the picked option adds.
in_cartbooleanalwaystrue while the picked option's lines are in the cart.
optionsSelectorOption[]optionalEvery option of a bundle or offer selector; none for a toggle.

CartItem

A line of the cart. Its prices are there once the server priced the cart.

FieldTypePresent
package_idnumberalwaysThe package's ref_id in the campaign.
quantitynumberalwaysPackage quantity.
is_upsellbooleanoptionaltrue for a line added after the order.
propertiesRecord<string, string>optionalLine properties, such as a variant picked in a bundle slot.
product_idnumbercampaignThe product in the store.
product_titlestringcampaignThe product's name as customers see it, as on an order line; the package's name for a package without one.
variant_idnumbercampaignThe product variant, for a product with variants.
variant_titlestringcampaignThe variant's name, such as Black / M, for a product with variants.
skustringcampaignThe product's Stock Keeping Unit.
imagestringcampaignThe package's image URL.
pricenumberpricedWhat one package costs after discounts.
original_pricenumberpricedWhat one package costs before discounts; equal to price when nothing is taken off.
total_discountnumberpricedThe discount on the line.
totalnumberpricedprice × quantity.
subtotalnumberpricedThe line before discounts: total = subtotal − total_discount.
discount_percentagenumberpricedtotal_discount ÷ subtotal × 100, to two decimals; 0 without a discount.
discountsDiscount[]pricedThe discounts on the line.
subscriptionSubscriptioncampaignFor a package billed again every interval.

SelectorOption

One option of a selector, at the quantity it would be added.

FieldTypePresent
pricenumberpricedtotal ÷ quantity: one package, after discounts.
original_pricenumberpricedsubtotal ÷ quantity: one package, before discounts.
subtotalnumberpricedWhat it costs before discounts.
total_discountnumberpricedsubtotal − total.
discount_percentagenumberpricedtotal_discount ÷ subtotal × 100, to two decimals.
option_idstringalwaysThe option's data-next-bundle-id, or data-next-option.
linesCartItem[]alwaysThe lines the option puts in the cart. Priced once the option has a price.
quantitynumberalwaysPackages the option adds: its lines' quantities.
selectedbooleanalwaystrue for the selector's picked option.
totalnumberpricedWhat the option costs after discounts.
original_totalnumberpricedWhat the option costs before discounts.

Discount

A discount on the cart's products or on its shipping. Amounts are in the cart's currency.

FieldTypePresent
namestringalwaysThe offer's name.
amountnumberalwaysThe amount taken off.
source"offer" | "coupon"alwayscoupon for a code the shopper entered (it is in coupons); offer for an automatic offer or a bundle card's own code.
codestringoptionalThe code, for a coupon.
offer_idnumberalwaysThe offer that gave it.
percentagenumberoptionalThe percentage the offer is set to take off, as the API reports it, such as 20. Its configured value, for a label such as “20% off”; the amount actually taken off is amount.

Subscription

A package billed again every interval.

FieldTypePresent
interval"day" | "month"alwaysThe unit of the renewal interval.
interval_countnumberalwaysHow many intervals between renewals.
pricenumberpricedWhat each renewal charges, after discounts.
original_pricenumberpricedWhat each renewal charges before discounts.