Next Commerce
Addon ToggleReference

Attributes

Complete reference of all Addon Toggle attributes. For guided explanations with examples, see Get Started, Displaying Prices, and Card Templates.

Container Attributes

AttributeDescription
data-next-package-toggleMarks the container (or the toggle element itself when used on a button); required to activate the Addon Toggle
data-next-include-shippingtrue / false — include shipping costs in price totals shown via data-next-toggle-display
data-next-packagesJSON array of package definitions for generating cards from a list; creates one card per entry when a template is also set
data-next-toggle-template-idID of a <template> element whose innerHTML is the card template
data-next-toggle-templateInline card template string (alternative to data-next-toggle-template-id)
data-next-upsell-contextSwitches the toggle to post-purchase upsell mode — clicks call the order API instead of the cart. Used on upsell/thank-you pages

Card Attributes

AttributeDescription
data-next-toggle-cardMarks an element as a toggleable card
data-next-package-idPackage ref_id — required per card
data-next-selected="true"Adds this package to the cart automatically on page load; will not be added again if already in the cart
data-next-quantityQuantity to add when toggling on (default 1); ignored when data-next-package-sync is set
data-next-package-syncComma-separated list of package IDs — quantity mirrors the sum of those packages currently in the cart
data-next-is-upsell="true"Marks the item as an upsell/bump for order tracking
data-next-urlNavigation URL after a successful upsell add; only used when data-next-upsell-context is set on the container. Falls back to a <meta name="next-upsell-url"> tag if not provided
data-add-textText shown in the button text target when the package is not in the cart
data-remove-textText shown in the button text target when the package is in the cart

Card Helper Attributes

Place these on elements inside a card to bind specific behaviors.

AttributeDescription
data-next-button-textMarks a child element as the text target for data-add-text / data-remove-text. When present, the button text is updated on this element instead of the card's own textContent
data-next-toggle-imageShorthand for data-next-toggle-display="image" on <img> elements — sets the src from the package image automatically

Price & Data Display

Place these on elements inside a card (or card template) to populate them with price and product data.

AttributeDescription
data-next-toggle-displayPrimary display field. Value is a field name (see table below).
data-next-toggle-priceOlder name for the same feature. Accepts the same field names as data-next-toggle-display. Use data-next-toggle-display in new markup.

Supported field names (work with both attributes):

FieldWhat it shows
packageIdPackage ref_id
namePackage display name
imagePackage image URL — sets src on <img> elements, textContent otherwise
quantityPackage quantity
variantNameProduct variant name
productNameProduct name
skuProduct SKU; empty if not set
priceFormatted total price for the card's quantity
unitPricePer-unit price
originalPriceRetail / compare-at total price
originalUnitPriceRetail / compare-at per-unit price
discountAmountSavings amount; empty if no discount
discountPercentageSavings as a percentage; empty if no discount
isSelectedShows the element when the package is in the cart; hides it otherwise
hasDiscountShows the element when a discount applies; hides it otherwise
isRecurringShows the element when the package bills on a recurring schedule; hides it otherwise
recurringPriceRecurring charge total (quantity-scaled)
originalRecurringPriceOriginal recurring price before discounts; empty if not available
intervalBilling interval: "day" or "month"
intervalCountNumber of intervals between billing cycles
frequencyHuman-readable cadence: "Per month", "Every 3 months", "One time"
currencyISO 4217 currency code

State Container Attribute

AttributeDescription
data-next-toggle-containerMarks an ancestor element as the state container for cards inside it. State classes and attributes are applied to this element instead of each card. See State Containers

Attributes Set Automatically

On each card element:

AttributeValuesWhen set
data-next-in-cart"true" / "false"Updated on every cart sync
data-next-loading"true" / "false"Set while a cart operation or price fetch is in progress

On the state container (when one is found):

AttributeValuesDescription
data-in-cart"true" / "false"Whether the package is in the cart
data-next-active"true" / "false"Alias for data-in-cart

Showing Data Outside a Card

Use data-next-display="toggle.{packageId}.{property}" on any element to bind it to a specific card's price or state. {packageId} must match data-next-package-id on the card.

<span data-next-display="toggle.201.price"></span>

Supported properties:

PropertyFormatDescription
packageIdtextPackage ref_id
nametextDisplay name from the campaign package
imageimagePackage image URL (sets src on <img> elements)
quantitytextPackage quantity
variantNametextProduct variant name
productNametextProduct name
skutextProduct SKU (empty if not set)
pricecurrencyTotal price for the card's quantity (unit price x quantity)
unitPricecurrencyPer-unit price
originalPricecurrencyRetail / compare-at total price
originalUnitPricecurrencyRetail / compare-at per-unit price
discountAmountcurrencySavings amount (compare minus total)
discountPercentagepercentageDiscount as a percentage of the compare price
isSelectedbooleantrue when this package is in the cart
hasDiscountbooleantrue when a discount is applied
isRecurringbooleantrue when the package bills on a recurring schedule
recurringPricecurrencyRecurring charge total (quantity-scaled)
originalRecurringPricecurrencyOriginal recurring price before discounts
intervaltextBilling interval: "day" or "month"
intervalCountautoNumber of intervals between billing cycles
frequencytextHuman-readable billing cadence: "Per month", "Every 3 months", "One time"
currencytextISO 4217 currency code

Supports all standard display modifiers: data-next-format, data-hide-if-zero, data-hide-if-false.


Discount Lists — data-next-discounts

Place inside a toggle card to show one row per discount applied to the package. Each container needs a <template> child defining the row markup.

Row placeholders: {discount.name}, {discount.amount}, {discount.description}.

CSS classes on the container:

ClassWhen
next-discounts-emptyNo discounts for this package
next-discounts-has-itemsOne or more discounts

Populated after each price fetch. Before the first fetch, the containers are empty and carry the next-discounts-empty class.

The offer/voucher filter (data-next-discounts="offer" / ="voucher") is not available at the toggle level — per-line discounts from the API are not split by type. Use the unfiltered data-next-discounts attribute.

See Displaying Prices — Discount Lists for usage examples.

On this page