"use client"; import { useCart, useCartForm } from "@/lib/cart"; import { content } from "@/lib/content"; import { formatPrice } from "@/lib/money"; import { CartLineItem } from "./CartLineItem"; /** * Shared cart content — line items, discount code form, and totals. Used by * both the cart drawer and the `/cart` page (`hydrogen-cart-ui` / * `hydrogen-cart-drawer`). The drawer wraps this in fixed header/body/footer * zones; the page wraps it in a page layout. * * Layout: the line-item list flexes to fill the available height and scrolls on * its own; the discount code + estimated-total block is pinned to the bottom * (feedback: bottom-align the footer block). The order note was removed — its * "save note" button was non-functional and the entry point is gone. */ export function CartContent() { const cart = useCart((state) => state.data); const loading = useCart((state) => state.loading); const lines = cart.lines.nodes; const totalQuantity = cart.totalQuantity; const subtotal = cart.cost.subtotalAmount; const discountCodes = cart.discountCodes; const { formProps, register } = useCartForm(); if (loading) { return (

Loading cart…

); } if (totalQuantity === 0 || lines.length === 0) { return (

{content.cart.empty}

{content.cart.emptyDescription}

); } return (
{/* Discount apply form */}
{/* Applied discount codes — each removal is its own form */} {discountCodes.map((code) => (
{code.code}
))} {/* Estimated total */}
{content.cart.totalLabel} {formatPrice(subtotal)}

{content.cart.taxesAndShippingAtCheckout}

); }