Shopping Cart with Summary
A full shopping cart layout: a line-item list with photo, name, variant, unit price, a quantity stepper, and a remove button, next to an order summary panel. The subtotal, shipping (free above a threshold, otherwise a flat fee), tax, and total all recompute live as the cart changes.
Docs
Installation
A real shadcn registry command, not a copy-paste stand-in: it fetches this block plus its button, media-slot dependencies and any missing npm packages, and installs them straight into your project.
npx shadcn add https://staaarter.com/r/shopping-cart-with-summary.jsonPrefer not to use the CLI? Copy the source from the Code toggle above into src/components/blocks/ecommerce/ecommerce14.tsx instead.
Usage
The file also exports ecommerce14Demo, the exact props behind the preview above. Spread it to get a working section in one line, then replace it with your own data.
import { Ecommerce14, ecommerce14Demo } from "@/components/blocks/ecommerce/ecommerce14"; export default function Page() { return <Ecommerce14 {...ecommerce14Demo} />; }
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| heading | string | "Your cart" | Heading above the cart layout. |
| items | CartLineItem[] | [] | Initial cart contents; copied into local state on first render so quantity changes and removals only affect this component's own state. |
| freeShippingThreshold | number | 7500 | Subtotal in cents at or above which shipping becomes free. |
| shippingCost | number | 800 | Flat shipping fee in cents charged when the subtotal is under the threshold. |
| taxRate | number | 0.08 | Tax rate applied to the subtotal, e.g. 0.08 for 8%. |
| className | string | none | Extra classes for the outer section element. |
Types
interface CartLineItem { id: string; name: string; variant?: string; unitPrice: number; // cents quantity: number; image?: { src: string; alt: string }; }
Behavior notes
- The cart is real client state: the quantity +/- buttons genuinely increment and decrement that line's quantity (clamped between 1 and 9, so decrementing to 0 is not possible from the stepper, only Remove drops a line entirely), and Remove genuinely deletes the item from the local cart array.
- The subtotal, shipping, tax, and total in the order summary are all recomputed live from the current cart state on every change, not just on mount: subtotal sums quantity times unit price across all lines, shipping is 0 once the subtotal reaches freeShippingThreshold and otherwise equals shippingCost, tax is the subtotal times taxRate rounded to the nearest cent, and total is the sum of all three.
- The demo cart starts at $72.00, three dollars under the $75.00 free-shipping threshold, so incrementing any single item's quantity by one is enough to flip the shipping line from $8.00 to Free live.
- Removing every item swaps the list for an empty-cart placeholder message and disables the Checkout button; the Checkout button itself is decorative and has no submit handler even with items in the cart.
- Money is stored and summed as integer cents throughout and only formatted to a dollar string at render time, so repeated quantity changes never accumulate floating-point rounding error.
More Ecommerce Blocks
View all →wishlist-manager
Wishlist Manager
Saved-items list with stock-status badges, move-to-cart and remove actions, and a real empty state.
product-information-tabs
Product Information Tabs
Tabbed product details with Description, Features, Specifications, Reviews, and Shipping panels.
collection-showcase-grid
Collection Showcase Grid
A large featured-collection hero card alongside a grid of smaller supporting collection tiles.
shop-by-brand-grid
Shop by Brand Grid
A grid of bordered brand tiles with a wordmark-style name, product count, and a hover affordance.
sale-countdown-timer
Sale Countdown Timer
A live days/hours/minutes/seconds countdown in default, compact, or full-width banner layouts.
gift-card-redemption-form
Gift Card Redemption Form
A code-entry form that validates against a fixed list of demo gift cards and shows a real success or error state.