cart-01-block
stackzero/cart-01-blockFreeBlock
stackzero publishes no description for this item.
Install it
npx shadcn@latest add https://ui.stackzero.co/r/cart-01-block.jsonSource
1"use client";23import PriceFormat from "@/components/commerce-ui/price-format-basic";4import QuantityInputBasic from "@/components/commerce-ui/quantity-input-basic";5import { Button } from "@/components/ui/button";6import { Loader2, ShoppingCart } from "lucide-react";78// Default logo placeholder9const DEFAULT_LOGO =10 "https://raw.githubusercontent.com/stackzero-labs/ui/refs/heads/main/public/placeholders/logo-placeholder.png";1112// Product item interface13interface CartProduct {14 id: string;15 name: string;16 price: number;17 quantity: number;18 imageUrl: string;19}2021// Cart checkout payload interface22interface CartCheckoutPayload {23 products: CartProduct[];24 subtotal: number;25 shippingCost: number;26 vatAmount: number;27 vatRate: number;28 totalAmount: number;29 currencyPrefix: string;30}3132// Cart component props33interface CartProps {34 storeName?: string;35 logoUrl?: string;36 products?: CartProduct[];37 subtotal?: number;38 shippingCost?: number;39 vatRate?: number;40 currencyPrefix?: string;41 isLoading?: boolean;42 errorMessage?: string;43 onCheckout?: (payload: CartCheckoutPayload) => void;44 onContinueShopping?: (payload: CartCheckoutPayload) => void;45 onUpdateQuantity?: (productId: string, newQuantity: number) => void;46 onRemoveProduct?: (productId: string) => void;47}4849// Default products for demo purposes50const DEFAULT_PRODUCTS: CartProduct[] = [51 {52 id: "prod-1",53 imageUrl:54 "https://raw.githubusercontent.com/stackzero-labs/ui/refs/heads/main/public/placeholders/headphone-1.jpg",55 name: "Wireless Headphones",56 price: 98.96,57 quantity: 1,58 },59 {60 id: "prod-2",61 imageUrl:62 "https://raw.githubusercontent.com/stackzero-labs/ui/refs/heads/main/public/placeholders/watch-1.jpg",63 name: "Smart Watch",64 price: 129.99,65 quantity: 2,66 },67];6869function Cart_01({70 currencyPrefix = "$",71 errorMessage = "",72 isLoading = false,73 logoUrl = DEFAULT_LOGO,74 onCheckout = () => {},75 onContinueShopping = () => {},76 onRemoveProduct = () => {},77 onUpdateQuantity = () => {},78 products = DEFAULT_PRODUCTS,79 shippingCost = 15.99,80 storeName = "TechGadgets",81 subtotal = 358.94, // This would typically be calculated from products82 vatRate = 0.2, // 20% VAT83}: CartProps = {}) {84 // Calculate VAT and total85 const vatAmount = subtotal * vatRate;86 const totalAmount = subtotal + shippingCost + vatAmount;8788 const isCartEmpty = !products || products.length === 0;8990 // Create the checkout payload91// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from stackzero
All 112 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| address-01-blockaddress-01-block | stackzero | Blocks | Free | 4 deps | |
| address-02-blockaddress-02-block | stackzero | Blocks | Free | 4 deps | |
| address-03-blockaddress-03-block | stackzero | Blocks | Free | 4 deps | |
| banner-01-blockbanner-01-block | stackzero | Blocks | Free | no deps | |
| banner-02-blockbanner-02-block | stackzero | Blocks | Free | no deps | |
| banner-03-blockbanner-03-block | stackzero | Blocks | Free | no deps | |
| banner-04-blockbanner-04-block | stackzero | Blocks | Free | no deps | |
| banner-05-blockbanner-05-block | stackzero | Blocks | Free | no deps |
