Block 72 of 297
Cart Summary
Cart as a real table with quantity inputs, remove links, a promo code form and an order summary with checkout link.
- Puck key
- CartSummaryBlock
- Export
- cartSummaryBlock
- React component
- <CartSummary />
- Path
- components/puck/cart-summary-block.tsx
- Dependencies
- None
- License
- MIT
About this block
When to use it, how to write for it, and what to change in the code.
What it's for
A shopping cart laid out as a data table with item, price, quantity and line total, each row with a quantity box and a remove link, beside an order summary with typed subtotal, discount, shipping, tax and total rows, an optional promo code form and a checkout button. On phones the unit-price column and thumbnails are hidden, and the summary follows the table.
- The cart page of a gift shop or merchandise store
- A ticket or registration cart before checkout
- A design reference for a cart your commerce platform renders
Writing the content
- Line items are usually bound to cart data. Nothing is calculated, so prices and totals must come from your system.
- Give each line a SKU so updates match the right item. A quantity of 0 removes it.
- Leave Promo code URL blank to hide the code form. An empty cart shows a message, and Checkout appears only with items.
- List Summary rows top to bottom: subtotal, discounts, shipping, tax.
Accessibility
- The cart is a real table with a hidden caption, column headers and each item name as a row header, so screen readers announce the item with each cell (WCAG 1.3.1).
- Each quantity box is labelled "Quantity of [item]" and each remove link reads "Remove [item]", so repeated controls stay distinct.
- The summary is an aside labelled by its heading, and its rows are a description list.
Customizing the code
- The shared focus style is the focusRing constant at the top of the file.
- Update posts sku[] and quantity[] arrays, and the promo form posts code. Adjust the names if your platform differs.
Editor fields
What content editors see in the P1 sidebar when they select this block.
- Headingtext
- Heading levelselect
- Line itemsarray
- Update cart URLtext
- Update button texttext
- Summary headingtext
- Summary rowsarray
- Total labeltext
- Totaltext
- Promo code URLtext
- Checkout button texttext
- Checkout linktext
- Keep shopping texttext
- Keep shopping linktext
- Notetextarea