Files
zeekay 09c5e16c5c feat: rebrand all packages to @hanzo/cms scope (Payload v3.85.2 fork)
- payload -> @hanzo/cms (core), bin payload -> hanzo-cms
- create-payload-app -> @hanzo/create-cms-app
- @payloadcms/<x> -> @hanzo/cms-<x> across the whole dependency graph
- 3545 files, 72 package.json, 4419 scoped refs, 3852 core import specifiers, 82 scss imports
- MIT attribution to Payload CMS Inc. preserved (LICENSE.md, author emails)

Upstream: github.com/payloadcms/payload @ v3.85.2 (MIT)
2026-07-01 17:56:00 -07:00

59 lines
1.6 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
'use client'
import { useCart, useCurrency } from '@hanzo/cms-plugin-ecommerce/react'
export const Cart = () => {
const { cart, incrementItem, decrementItem, removeItem, subTotal, clearCart } = useCart()
const { formatCurrency } = useCurrency()
return (
<div>
<h1>Cart Component</h1>
<p>This is a placeholder for the Cart component.</p>
<p>subTotal: {formatCurrency(subTotal)}</p>
{cart && cart.size > 0 ? (
<ul>
{Array.from(cart.values()).map((item, index) => {
const id = item.variantID || item.productID
const options =
item.variant?.options && item.variant.options.length > 0
? item.variant.options
.filter((option) => typeof option !== 'string')
.map((option) => {
return option.label
})
: []
return (
<li key={id}>
<h2>
{item.product.name} {options.length > 0 ? `(${options.join(' – ')})` : ''}
</h2>
<p>Quantity: {item.quantity}</p>
<button onClick={() => incrementItem(id)}>+</button>
<button onClick={() => decrementItem(id)}>-</button>
<button onClick={() => removeItem(id)}>Remove</button>
</li>
)
})}
</ul>
) : (
<p>Your cart is empty.</p>
)}
<button
onClick={() => {
clearCart()
}}
>
Clear all
</button>
{/* <pre>{JSON.stringify(Array.from(cart.entries()), null, 2)}</pre> */}
</div>
)
}