Cart changes grouped — Storefront block

Free

storefront-cart-changes-grouped · for cart, checkout pages

Cart changes grouped

The changes sorted under "Prices", "Quantities" and "Sold out", each a short ruled list: a long or trade cart where many lines moved at once

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-grouped

Usage

Its demo data, shortened (Using blocks).

<script setup lang="ts">
import StorefrontCartChangesGrouped from '@/components/trame/blocks/storefront/storefront-cart-changes-grouped.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>
<StorefrontCartChangesGrouped v-bind="props" />
</template>

Props

Each prop says who changes it: Words, Picture, Action, Design, Data.* required.

PropTypeDescription
title*stringWordsthe notice’s heading ("Your cart has changed")
introstringWordsone 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
actionsActionsthe page actions the block runs, each described below
optionsOptionsthe block’s settings: layout choices and secondary words, read by every variant
Change changes[] · 7 props
PropTypeDescription
id*string | numberDatathe record’s id in the tool that answers it
variantstringWordsthe chosen options, written out ("Navy · 42")
product*Productthe 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
beforenumberthe value the customer saw: the unit price in cents for a price, the units for a quantity
afternumberthe value now, in the same unit
notestringWordswhat the shop knows ("Restock expected on 8 July")
Product changes[].product · 5 props
PropTypeDescription
id*string | numberDatathe record’s id in the tool that answers it
name*stringWordsthe product’s name
imagestring | nullPicturethe main picture; null or absent: the product has none yet
altstringWordswhat the main picture shows
currencystringDesignISO 4217, EUR by default
Actions actions · 3 props
PropTypeDescription
removestringActiontakes a line out of the cart (default cart.remove); posts line
notifystringActionasks to be told when a sold-out product is back; posts line
proceedProceedthe proceed action: its words and the page action it runs
Proceed actions.proceed · 2 props
PropTypeDescription
label*stringWords"Got it, continue"
action*stringActiona named action of the page
Options options · 1 props
PropTypeDescription
mood'inverse' | 'brand' | 'warm' | 'tint' | stringa 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).

MemberWhat it is for
hrefthe address an action leads to, or null to hide what leads there
actruns a change (subscribe, add to cart, save) and answers { ok } or { ok: false, error }
canwhether the page has this action
moneyformats a price, given in cents
Linkyour router’s link component
cartCountthe cart badge’s number
cartDrawerwhether your app has a cart drawer
cartOpenwhether the cart drawer is open
labelyour 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:

KeyEnglishFrench
newsletter.alreadyYou are already subscribed.Vous êtes déjà inscrit.
newsletter.doneDone: you are subscribed.C’est noté : vous êtes inscrit.
newsletter.invalidCheck the email address.Vérifiez l’adresse e-mail.
newsletter.tooManyToo 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 cart from 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 builder toggle list: the main product, add-ons with switches and a sticky total bar: the visitor builds the set one choice at a time.
  • Bundle offer list: a kit of several products: each piece with its solo price, the bundle’s price and the saving computed from them.
  • 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.

All 409 storefront blocks