Cart changes notice — Storefront block
Freestorefront-cart-changes-notice · for cart, checkout pages
Cart changes notice
One bordered notice above the cart that says each change in a plain sentence, with a way out for what sold out: one to three changes, the cart itself shown under it
Documentation
Installation
One command copies the block into your project with the shadcn CLI (the registry is set once: Installation).
pnpm dlx shadcn-vue@latest add @trame/storefront-cart-changes-noticeUsage
Its demo data, shortened (Using blocks).
<script setup lang="ts">
import StorefrontCartChangesNotice from '@/components/trame/blocks/storefront/storefront-cart-changes-notice.vue'
const props = {
title: "Your cart has changed",
intro: "A cart doesn’t hold stock: here’s what has changed since your last visit.",
changes: [
{
id: "l1",
product: {
id: "pull-gris",
name: "Heathered wool sweater",
image: "https://images.unsplash.com/photo-1580841831267-17e30b6b4a8b?w=320&q=80",
alt: "A gray knit sweater laid flat on a table"
},
variant: "Size M",
kind: "price-down",
before: 11900,
after: 9900
},
{
id: "l2",
product: {
id: "bonnet",
name: "Ribbed beanie",
image: "https://images.unsplash.com/photo-1664289321749-07316ab5e374?w=320&q=80",
alt: "A gray ribbed beanie"
},
variant: "Gray",
kind: "quantity",
before: 3,
after: 2
}
],
actions: {
notify: "stock.notify",
proceed: {
label: "Got it, continue",
action: "checkout"
}
}
}
</script>
<template>
<StorefrontCartChangesNotice v-bind="props" />
</template>Props
Each prop says who changes it: Words, Picture, Action, Design, Data.* required.
| Prop | Type | Description |
|---|---|---|
| title* | string | Wordsthe notice’s heading ("Your cart has changed") |
| intro | string | Wordsone line on why ("A cart does not reserve stock; here is what changed since your last visit.") |
| changes* | Change[] | Datathe lines that changed, as the cart tool answers them: never computed here |
| actions | Actions | the page actions the block runs, each described below |
| options | Options | the block’s settings: layout choices and secondary words, read by every variant |
Change changes[] · 7 props
| Prop | Type | Description |
|---|---|---|
| id* | string | number | Datathe record’s id in the tool that answers it |
| variant | string | Wordsthe chosen options, written out ("Navy · 42") |
| product* | Product | the product that changed |
| kind* | 'price-down' | 'price-up' | 'quantity' | 'sold-out' | what changed: the price went down or up, the quantity was lowered to the stock, or the product sold out |
| before | number | the value the customer saw: the unit price in cents for a price, the units for a quantity |
| after | number | the value now, in the same unit |
| note | string | Wordswhat the shop knows ("Restock expected on 8 July") |
Product changes[].product · 5 props
| Prop | Type | Description |
|---|---|---|
| id* | string | number | Datathe record’s id in the tool that answers it |
| name* | string | Wordsthe product’s name |
| image | string | null | Picturethe main picture; null or absent: the product has none yet |
| alt | string | Wordswhat the main picture shows |
| currency | string | DesignISO 4217, EUR by default |
Actions actions · 3 props
| Prop | Type | Description |
|---|---|---|
| remove | string | Actiontakes a line out of the cart (default cart.remove); posts line |
| notify | string | Actionasks to be told when a sold-out product is back; posts line |
| proceed | Proceed | the proceed action: its words and the page action it runs |
Proceed actions.proceed · 2 props
| Prop | Type | Description |
|---|---|---|
| label* | string | Words"Got it, continue" |
| action* | string | Actiona named action of the page |
Options options · 1 props
| Prop | Type | Description |
|---|---|---|
| mood | 'inverse' | 'brand' | 'warm' | 'tint' | string | a band of the page that redefines the theme surfaces inside it |
What it asks your app for
The block never knows your app: it asks it, through one context provided once, where its links lead, what its actions do, how a price reads and which words to say (The host context).
| Member | What it is for |
|---|---|
| href | the address an action leads to, or null to hide what leads there |
| act | runs a change (subscribe, add to cart, save) and answers { ok } or { ok: false, error } |
| can | whether the page has this action |
| money | formats a price, given in cents |
| Link | your router’s link component |
| cartCount | the cart badge’s number |
| cartDrawer | whether your app has a cart drawer |
| cartOpen | whether the cart drawer is open |
| label | your word for an interface key, or undefined to keep the block’s own |
The words it says itself, in English and French; label(key) replaces any of them:
| Key | English | French |
|---|---|---|
| newsletter.already | You are already subscribed. | Vous êtes déjà inscrit. |
| newsletter.done | Done: you are subscribed. | C’est noté : vous êtes inscrit. |
| newsletter.invalid | Check the email address. | Vérifiez l’adresse e-mail. |
| newsletter.tooMany | Too many attempts, try again in a moment. | Trop de tentatives, réessayez dans un moment. |
Features
- Every word in the server HTML
- Same markup in Vue and React
- Theme tokens only: every theme, light and dark
- Shows what you give it, invents nothing
- No motion; still under reduced motion
- Real buttons and links, a visible focus
- Asks your app through actions:
actions.remove,actions.notify,actions.proceed - Reads
cartfrom your app
A storefront section, for cart, checkout pages; it uses @lucide/vue, class-variance-authority, clsx, reka-ui, tailwind-merge.
More storefront blocks
- Bundle sum table: the products listed with their prices and the sum written out as an equation, no discount: when the bundle is a convenience, not a deal.
- Cart bar dock: a bottom bar with the count, the total and the pay button, opening on the lines: for shops where the cart is the page’s main task.
- Cart bar floating pill: a rounded pill centred over the page with the pictures stacked, the count, the total and the pay button, the lines opening in a card above it: for a light shop where the cart should stay discreet while the visitor keeps browsing.
- Cart drawer dialog: a centred confirmation after an addition: the lines with their quantities and one "Confirm" that leads to checkout.
- Cart drawer popover: a small card under the header’s cart icon: three lines at most, then "View cart".
- Cart drawer tiles: a wide drawer whose lines are picture tiles in a grid, totals and buttons pinned at the foot: picture-led shops (beauty, fashion) with two to six lines, where a product is recognised by its picture.
- Cart drawer: the cart from anywhere, as a full-height panel: the lines scroll, the totals and the way to pay stay pinned at the bottom.
- Cart lines and summary: the usual cart: lines on the left, a sticky summary on the right, a "Checkout" bar on a phone.