Next Commerce
Data AttributesActionsReference

Attributes

Every action attribute, grouped by purpose.


Activation

AttributeRequiredDescription
data-next-action="<name>"yes (one of)Activates the matching action enhancer. See action values below
data-next-toggle="cart"yes (one of)Activates CartToggleEnhancer — the toggle pattern
data-next-quantity="increase|decrease|input"yes (one of)Activates QuantityControlEnhancer

Action Values

data-next-action=EnhancerDescription
add-to-cartAddToCartEnhancerAdd a package to the cart
removeRemoveItemEnhancerRemove a package from the cart
clear-cartClearCartEnhancerEmpty the entire cart
swapSwapPackageEnhancerReplace cart contents with one package atomically
accept-upsellAcceptUpsellEnhancerSubmit a post-purchase upsell. See Upsells → Accept Button

Package Targeting

AttributeUsed byDescription
data-next-package-idAll actionsPackage ref_id to target
data-next-quantityadd-to-cart, swapQuantity to add or set. Default 1
data-next-selector-idadd-to-cart, accept-upsellRead the package from a linked PackageSelectorEnhancer instead of using data-next-package-id
data-next-package-syncdata-next-toggle="cart"Comma-separated package IDs whose total quantity mirrors this toggle

Modifiers

AttributeDescription
data-next-clear-cartWhen true, clear the cart before performing the action
data-next-urlURL to navigate to after the action completes
data-stepStep value for data-next-quantity="increase" / "decrease". Default 1

State Container

AttributeDescription
data-next-state-containerMarks an element as a state container. Children with data-next-state="<state>" are shown selectively
data-next-state="in-cart"Show this child when the bound package is in the cart
data-next-state="not-in-cart"Show this child when the bound package is not in the cart
data-next-state="loading"Show this child while an action is in flight

Text State

AttributeWhen the text is shown
data-add-textWhen the package is not in the cart
data-remove-textWhen the package is in the cart
data-loading-textWhile an async action is in flight

The SDK rewrites the element's text content when the state changes.


CSS Classes Managed

ClassApplied when
next-loadingAn async action is in flight on this element
next-in-cartThe bound package is in the cart
next-disabledThe action cannot be triggered (no order, no selection, processing, etc.)
next-activeThe toggle is in the "active" state (item in cart)

The native disabled attribute is also toggled alongside next-disabled.


On this page