Order Summary

View as Markdown

What an order comes to: its lines, then subtotal, discount, shipping, tax and the total.

Order summary

  • Waxed canvas toteOat · Largewas $85.00$68.00
  • Stoneware mugSlate · 2 × $24.00$48.00
  • Merino socks, three pairsM$32.00
Subtotal
$148.00
DiscountWELCOME10
−$14.80
Shipping
Free
Tax
$10.99
Total
USD$144.19

When to use

What an order comes to: its lines, then subtotal, discount, shipping, tax and the total. Use Fact Grid instead when the numbers don't add up to a total.

Usage

import { OrderSummary } from "./ui/uicontext/components/OrderSummary.ts"
export const Summary = <M>(h: Html.H<M>) =>	OrderSummary(h, { currency: "USD", lines: [{ id: "mug", name: "Stoneware mug", quantity: 2, unitPrice: 2400 }], shipping: 0, taxRate: 0.0825 })

Examples

Tax included, in euros

taxIncluded shows the VAT inside the prices rather than adding it; locale writes the amounts.

  • Business planAnnual · 12 × 144,00 €1.728,00 €
  • SSO add-onAnnual · 1 × 480,00 €480,00 €
Subtotal
2.208,00 €
Shipping
Free
Including VAT
352,54 €
Total
EUR2.208,00 €

API reference

Options

OrderSummary options
NameTypeDefaultDescription
linesrequiredOrderLine[]—What was ordered, in the order shown.
currencyrequiredstring—ISO 4217: "USD", "EUR", "JPY".
discount{ readonly label: string; readonly amount: number }—Off the subtotal, in minor units, with the code or reason: { label: "WELCOME10", amount: 1200 }.
shippingnumber—In minor units; 0 reads "Free". Leave out while it isn't known yet.
taxRatenumber—A rate such as 0.0825, applied to the subtotal after the discount.
taxIncludedboolean—Tax already in the prices, as in much of Europe: shown as "Including VAT", not added.
taxLabelstring"Tax"The tax line's name; "Tax" by default, "VAT" or "GST" elsewhere.
titlestring—A heading over it: "Order summary".
cardboolean—Draws it on a bordered card.
localestring——
styleStyle——

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/order-summary

Source