Next Commerce
Addon Toggle

Displaying Prices

Inside Toggle Cards

Place [data-next-toggle-display] inside a card or its template. Prices are fetched automatically and these elements are populated with formatted values.

<span data-next-toggle-display="price"></span>                        <!-- total price -->
<span data-next-toggle-display="unitPrice"></span>            <!-- per-unit price -->
<span data-next-toggle-display="originalPrice"></span>        <!-- retail / compare-at total price -->
<span data-next-toggle-display="originalUnitPrice"></span>    <!-- retail / compare-at per-unit price -->
<span data-next-toggle-display="discountAmount"></span>       <!-- savings amount -->
<span data-next-toggle-display="discountPercentage"></span>   <!-- savings percentage -->
<span data-next-toggle-display="name"></span>                 <!-- package display name -->
<span data-next-toggle-display="isSelected"></span>           <!-- shown when the package is in the cart; hidden otherwise -->
<span data-next-toggle-display="hasDiscount"></span>          <!-- shown when a discount applies; hidden otherwise -->
<span data-next-toggle-display="isRecurring"></span>          <!-- shown when recurring; hidden otherwise -->
<span data-next-toggle-display="recurringPrice"></span>       <!-- recurring charge total -->
<span data-next-toggle-display="interval"></span>             <!-- "day" or "month" -->
<span data-next-toggle-display="intervalCount"></span>        <!-- number of intervals between billing cycles -->
<span data-next-toggle-display="frequency"></span>            <!-- "Per month", "Every 3 months", "One time" -->
<span data-next-toggle-display="currency"></span>             <!-- ISO currency code -->

Boolean fields (hasDiscount, isRecurring, isSelected) show or hide the element via display — they do not write text. All other fields set textContent. Unrecognized values leave the element unchanged.

data-next-toggle-price is still supported and accepts the same field names. Prefer data-next-toggle-display in new markup.

Prices for in-cart items are read directly from the cart summary — no extra API call. Prices for not-in-cart items are fetched via /calculate with the item simulated in the cart, so offer discounts that depend on cart total are correctly reflected.

A next-loading class and data-next-loading="true" are set on the card element while a fetch is in progress.

Prices are re-fetched automatically when:

  • The cart changes (items added, removed, or quantity updated)
  • Applied vouchers change
  • The active currency changes

External Price Display

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

<span data-next-display="toggle.201.price"></span>
<span data-next-display="toggle.201.originalPrice"></span>
<span data-next-display="toggle.201.discountAmount" data-hide-if-zero="true"></span>
<span data-next-display="toggle.201.isSelected"></span>

Supported properties:

PropertyFormatDescription
isSelectedbooleantrue when this package is in the cart
nametextDisplay name from the campaign package
pricecurrencyTotal price for the card's quantity (unit price × 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
hasDiscountbooleantrue when a discount is applied
isRecurringbooleantrue when the package bills on a recurring schedule
recurringPricecurrencyRecurring charge total (quantity-scaled)
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.

External display elements update when the toggle card's price is fetched (toggle:price-updated) or when the cart selection changes (toggle:selection-changed). The card must be present in the DOM before the display element resolves.


Include Shipping in Prices

Add data-next-include-shipping="true" to the container to include shipping costs in the price totals shown via data-next-toggle-display.

<div data-next-package-toggle data-next-include-shipping="true">
  <div data-next-toggle-card data-next-package-id="201">
    <span data-next-toggle-display="price"></span>
  </div>
</div>

On this page