Next Commerce
Data AttributesSelectionReference

Attributes

Selector Container

AttributeRequiredDescription
data-next-cart-selectoryesMarks the container element
data-next-selector-idyesUnique ID for this selector. Used by data-next-display="selection.<id>.<prop>" and by add-to-cart buttons
data-next-selection-modenoswap (default — write to cart immediately) or select (track selection only)
<div data-next-cart-selector
     data-next-selector-id="main-product"
     data-next-selection-mode="swap">
  <!-- cards -->
</div>

Selector Cards

AttributeRequiredDescription
data-next-selector-cardyesMarks an element as a selectable card
data-next-package-idyesPackage ref_id for this card
data-next-selected="true"noPre-selects this card on init
data-next-quantitynoInitial quantity for this card. Default 1
data-next-min-quantitynoMinimum allowed quantity. Default 1
data-next-max-quantitynoMaximum allowed quantity. Default 999
data-next-shipping-idnoDefault shipping method to apply when this card is selected

Quantity Controls (inside a card)

AttributeDescription
data-next-quantity-increaseIncrement button. Auto-disabled at max
data-next-quantity-decreaseDecrement button. Auto-disabled at min
data-next-quantity-displayElement whose text content reflects the current quantity
<div data-next-selector-card data-next-package-id="2"
     data-next-quantity="1" data-next-min-quantity="1" data-next-max-quantity="10">
  <button data-next-quantity-decrease>−</button>
  <span data-next-quantity-display>1</span>
  <button data-next-quantity-increase>+</button>
</div>

Display Bindings

data-next-display="selection.<selectorId>.<property>" binds any element to the currently selected card's data.

Identity

PropertyTypeDescription
namestringSelected package name
packageIdnumberSelected package ID
quantitynumberQuantity selected
hasSelectionbooleantrue when at least one card is selected

Pricing

PropertyTypeDescription
pricecurrencyUnit price
unitPricecurrencyPrice per unit
totalcurrencyUnit price × quantity
compareTotalcurrencyOriginal total before discounts

Calculated

PropertyTypeDescription
savingsAmountcurrencyTotal savings
savingsPercentagenumberSavings as a percentage
hasSavingsbooleantrue when savings > 0
isBundlebooleantrue when the package is a multi-pack
totalUnitsnumberTotal units in the selection

Use .raw for the numeric value: data-next-display="selection.main-product.total.raw" returns a plain number suitable for math operators.


Cross-Container Sync

When two selectors share the same data-next-selector-id value, selecting in one syncs the selection to the other. Useful for sticky headers and side-by-side comparison views.


On this page