Skip to main content

CartSummary

Displays a structured overview of shopping cart totals: subtotal, discounts, shipping costs, VAT breakdowns, and the final total. Receives a Cart object as a prop and renders each line item with granular visibility controls. An optional checkout button can trigger navigation or custom checkout logic.

Usage

Basic summary with checkout button

import CartSummary from '@/components/propeller/CartSummary';

<CartSummary
cart={cart}
onCheckoutButtonClick={(cart) => router.push('/checkout')}
/>

With checkout button and custom title

<CartSummary
cart={cart}
title="Your Order"
onCheckoutButtonClick={(cart) => router.push('/checkout')}
/>

Read-only summary (no checkout button)

<CartSummary
cart={cart}
showCheckoutButton={false}
/>

Minimal summary (total only)

<CartSummary
cart={cart}
showSubtotal={false}
showDiscount={false}
showShippingCosts={false}
showVATs={false}
showTotalExclVat={false}
showTotalVat={false}
showCheckoutButton={false}
/>

Custom labels and price formatting

<CartSummary
cart={cart}
labels={{
subtotal: 'Subtotaal:',
discount: 'Korting:',
shippingCosts: 'Verzendkosten:',
totalExclVat: 'Totaal excl. BTW:',
vat: 'BTW',
totalVat: 'Totaal BTW:',
total: 'Totaal:',
checkoutButton: 'Afrekenen',
}}
formatPrice={(price) => `$ ${price.toFixed(2)}`}
onCheckoutButtonClick={(cart) => router.push('/checkout')}
/>

Configuration

Data

PropTypeRequiredDefaultDescription
cartCartYes--The shopping cart object used to populate all summary data

Display toggles

PropTypeDefaultDescription
showSubtotalbooleantrueShow the subtotal row
showDiscountbooleantrueShow the discount row (only visible when a discount exists)
showShippingCostsbooleantrueShow the shipping costs row (only visible when shipping costs exist)
showVATsbooleantrueShow individual VAT level rows
showTotalExclVatbooleantrueShow the total excluding VAT row
showTotalVatbooleantrueShow the combined total VAT row
showCheckoutButtonbooleantrueShow the checkout button

Customization

PropTypeDefaultDescription
titlestring'Order summary'Heading text above the summary
labelsRecord<string, string>See labels table belowOverride any display label
formatPrice(price: number) => stringFormats as €X.XXCustom price formatting function

Callbacks

PropTypeDescription
onCheckoutButtonClick(cart: Cart) => voidCalled when the checkout button is clicked. Receives the current cart object.

Labels

All text labels can be overridden via the labels prop. Pass a Record<string, string> with any of these keys:

KeyDefault value
subtotalSubtotal:
discountDiscount:
shippingCostsShipping costs:
totalExclVatTotal excl. VAT:
vatVAT
totalVatTotal VAT:
totalTotal:
checkoutButtonContinue to Checkout

Behavior

Row visibility

Each summary row is controlled by its corresponding show* prop. All default to true.

  • Subtotal -- always rendered when showSubtotal is true.
  • Discount -- only rendered when showDiscount is true AND cart.total.discount > 0. The value is displayed with a leading minus sign.
  • Shipping costs -- only rendered when showShippingCosts is true AND cart.postageData.price > 0.
  • Total excl. VAT -- rendered when showTotalExclVat is true. Displayed with a top border to visually separate it from the rows above.
  • VAT breakdown -- rendered when showVATs is true AND there are tax levels with both taxPercentage > 0 and price > 0. Each level is shown as a separate row (e.g., "21% VAT: ...").
  • Total VAT -- rendered when showTotalVat is true AND the computed total VAT is greater than zero.
  • Total (incl. VAT) -- always rendered. This row cannot be hidden; it is the primary output of the component.
  • Checkout button -- rendered when showCheckoutButton is true. Clicking it calls onCheckoutButtonClick with the current cart.

Price formatting

By default, prices are formatted as €X.XX (euro sign followed by the number with two decimal places). Pass a formatPrice function to override this for any currency or locale.

Layout

The component renders as a vertical stack of rows. Each row is a flex container with the label on the left and the formatted price on the right. The total row and the total-excl-VAT row include top borders for visual separation. The checkout button spans the full width below the total.

SDK Services

CartSummary is a display-only component -- it does not call any SDK services itself. It receives a Cart object (from propeller-sdk-v2) as a prop and reads the following fields:

Cart fields used

FieldTypePurpose
cart.total.subTotalnumberLine items subtotal before discounts
cart.total.discountnumberTotal discount amount applied to the cart
cart.total.totalGrossnumberCart total excluding VAT
cart.total.totalNetnumberCart total including VAT (the final price)
cart.postageData.pricenumberShipping / postage costs
cart.taxLevelsArray<{ taxPercentage: number; price: number }>Individual VAT rates and their amounts

The total VAT amount is computed as totalNet - totalGross (not read from a single field).