Next Commerce
Cart SummaryReference

Attributes

Host Element

data-next-cart-summary

Typeboolean (presence)
Requiredyes

Marks the element as a cart summary block. Place on the outermost container element.

<div data-next-cart-summary></div>

Template Tokens

Place inside a <template> direct child of data-next-cart-summary. Unrecognized tokens are left unchanged.

TokenTypeDescription
{subtotal}currencySum of all line item prices at campaign rates — after sale pricing, before promotions and shipping
{total}currencyGrand total: subtotal + shipping − discounts
{shipping}currency / textShipping charge; "Free" when zero
{shippingOriginal}currencyOriginal shipping before a discount; empty string when no shipping discount is active
{shippingDiscountAmount}currencyAbsolute amount saved on shipping
{shippingDiscountPercentage}percentageShipping discount as a percentage (e.g. "10%")
{shippingName}textDisplay name of the selected shipping method
{shippingCode}textCode of the selected shipping method
{totalDiscount}currencyCombined offer and voucher discount amount
{totalDiscountPercentage}percentageTotal discount as a percentage of subtotal (e.g. "20%")
{discounts}currencyDeprecated alias for {totalDiscount} — still rendered
{currency}textActive currency code (e.g. "USD")
{itemCount}textNumber of distinct package lines in the cart (e.g. "3")
{totalQuantity}textTotal unit quantity across all lines (e.g. "5")
{isEmpty}text"true" or "false" — whether the cart has no items
{hasDiscounts}text"true" or "false" — whether any discount is applied
{isFreeShipping}text"true" or "false" — whether shipping cost is zero
{hasShippingDiscount}text"true" or "false" — whether a shipping discount is applied
{isCalculating}text"true" or "false" — whether a totals recalculation is in progress

List Container Attributes

Place these on elements inside a <template> child. Each container must also include a <template> child defining the row markup. A container without a <template> child is silently ignored.

All list containers receive these state classes after each render:

ClassCondition
next-summary-emptyNo items in this list
next-summary-has-itemsOne or more items in this list

data-summary-lines

Renders one row per cart line. Lines are sorted by package_id ascending.

Row tokens: see Object Attributes → SummaryLine.

data-summary-offer-discounts

Renders one row per offer (promotion) discount.

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

data-summary-voucher-discounts

Renders one row per voucher (coupon) discount.

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

data-line-discounts

Place inside a data-summary-lines row template to render per-line discount breakdowns.

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

Receives next-summary-empty / next-summary-has-items classes.


Per-Line Conditional Display

Inside any line or discount row template, use data-next-show and data-next-hide to render rows conditionally per row. Conditions are evaluated at render time against the same data used for token replacement, so you do not need any global setup. Hidden elements are removed from the DOM and the attribute is stripped, so global show/hide processing never re-processes them.

<ul data-summary-lines>
  <template>
    <li>
      <span>{item.name}</span>
      <span data-next-show="item.quantity > 1">×{item.quantity}</span>
      <span data-next-hide="item.hasDiscount">{item.price}</span>
      <span data-next-show="item.isRecurring">Renews {item.frequency}</span>
    </li>
  </template>
</ul>

Syntax rules

  • Use the no-braces syntax. Write item.quantity > 1, not {item.quantity} > 1 — the latter is substituted before evaluation and produces a malformed expression.
  • Supported operators: >, >=, <, <=, ==, ===, !=, !==, &&, ||, !, parentheses.
  • A bare property is interpreted as a truthy check: data-next-show="item.isRecurring".
  • Conditions referencing other namespaces (e.g. cart.hasItems) are passed through untouched and processed by the global show/hide system. Avoid cart-wide conditions inside line templates — they thrash on every cart re-render. Place them outside the data-summary-lines template instead.
  • Function-call conditions (e.g. item.hasFlag(x)) are not handled.

item.* namespace

Available in data-summary-lines row templates and inside any nested data-line-discounts template.

PathTypeDescription
item.packageIdnumberPackage ref_id
item.namestringPackage display name
item.imagestringProduct image URL
item.quantitynumberUnit quantity for this line
item.productNamestringProduct name
item.variantNamestringVariant name (empty when no variant)
item.skustringProduct SKU
item.isRecurringbooleanWhether the line is a subscription
item.interval'day' | 'month' | nullSubscription interval
item.intervalCountnumber | nullSubscription interval count
item.frequencystringHuman-readable frequency (e.g. "Monthly", "Every 7 days")
item.recurringPricenumber | nullRecurring unit price
item.originalRecurringPricenumber | nullOriginal recurring unit price
item.pricenumberPackage price after discounts
item.originalPricenumberPackage price before discounts
item.unitPricenumberUnit price after discounts
item.originalUnitPricenumberUnit price before discounts
item.discountAmountnumberTotal discount on the line
item.discountPercentagenumberDiscount as a percentage of original (e.g. 25 for 25%)
item.hasDiscountbooleanWhether the line has any discount applied
item.currencystringActive currency code

Raw values vs text tokens

The item.* paths used in conditions are raw types — item.hasDiscount is a real boolean, item.unitPrice is a real number. The same paths used as {item.*} text tokens still render as currency-formatted strings or "show" / "hide" for backwards compatibility.

discount.* namespace

Available in data-summary-offer-discounts, data-summary-voucher-discounts, and data-line-discounts row templates.

PathTypeDescription
discount.namestringOffer or voucher name
discount.amountnumberDiscount amount as a raw number (currency symbols stripped)
discount.amountFormattedstringOriginal currency-formatted amount string
discount.descriptionstringOffer or voucher description

Examples

<!-- Show only when quantity > 1 -->
<span data-next-show="item.quantity > 1">×{item.quantity}</span>

<!-- Hide when the line has a discount -->
<span data-next-hide="item.hasDiscount">{item.price}</span>

<!-- Logical combinations -->
<span data-next-show="item.isRecurring && item.discountPercentage >= 10">
  Subscriber bonus
</span>

<!-- NOT operator -->
<span data-next-show="!item.isRecurring">One-time purchase</span>

<!-- Discount-side conditions -->
<li data-next-show="discount.amount >= 5">{discount.name} -{discount.amountFormatted}</li>

Cart Display — data-next-display

Typestring
Requiredyes
Formatcart.{property}

Places a single reactive cart value on the element. Updates automatically on every cart change.

<span data-next-display="cart.total"></span>

Supported properties

Financial totals

PropertyFormatDescription
cart.subtotalcurrencySubtotal before shipping and discounts
cart.totalcurrencyGrand total after all discounts and shipping
cart.totalDiscountcurrencyCombined offer and voucher discount amount
cart.totalDiscountPercentagepercentageTotal discount as a percentage of the subtotal
cart.shippingcurrencyShipping cost
cart.shippingOriginalcurrencyOriginal shipping before a shipping discount; $0.00 when no discount
cart.shippingDiscountAmountcurrencyAbsolute shipping discount
cart.shippingDiscountPercentagepercentageShipping discount percentage
cart.shippingNametextDisplay name of the selected shipping method
cart.shippingCodetextCode of the selected shipping method

Cart status

PropertyFormatDescription
cart.itemCountnumberNumber of distinct line items
cart.totalQuantitynumberTotal unit quantity across all lines
cart.isEmptyboolean"Yes" / "No"
cart.hasDiscountsboolean"Yes" / "No"
cart.isFreeShippingboolean"Yes" / "No"
cart.hasShippingDiscountboolean"Yes" / "No"
cart.isCalculatingboolean"Yes" / "No"
cart.currencytextActive currency code (e.g. USD)

Per-item quantity:

<span data-next-display="cart.items[2].quantity"></span>

Optional modifiers

AttributeEffect
data-hide-if-zeroHide the element when the value is 0
data-hide-if-falseHide the element when the value is falsy
data-hide-zero-centsOmit .00 from currency output
data-next-formatOverride format: currency, number, boolean, percentage, text, auto

On this page