CartLine
CartLine shows one cart line in the cart's columns, with the quantity, the name and its attributes, the unit price, and the line total.
Import
import { CartLine } from '@tallyui/components';Usage
<CartLine
name="Shirt"
attributes={{ Size: 'M', Colour: 'Red' }}
quantity={2}
unitPrice={{ amount: 1500, currency: 'EUR' }}
regularUnitPrice={{ amount: 2300, currency: 'EUR' }}
lineTotal={{ amount: 3000, currency: 'EUR' }}
/>The line sits in the same columns as CartColumnHeads: Qty, Item, Price and Total. The attributes appear on one line under the name, as "Size: M · Colour: Red". A simple line with no attributes shows none. When the regular price is above the unit price, the regular price is shown struck through above it, labelled "Regular price …" for screen readers.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
name | string | required | The line's name |
attributes | Record<string, string> | — | The variant's chosen options, shown under the name |
quantity | number | required | The quantity |
unitPrice | Money | required | The unit price |
regularUnitPrice | Money | — | The regular unit price; struck through only when it is above unitPrice in the same currency |
lineTotal | Money | required | The line total, shown as given |
showPrice | boolean | true | Shows the Price column; pass the same value as CartColumnHeads |
quantitySlot | ReactNode | — | Replaces the quantity's text, e.g. a LinePopover |
priceSlot | ReactNode | — | Replaces the unit price's text; the struck regular price stays above it |
columns | CartColumnSettings | — | Which columns show, as CartColumnHeads' columns (v2's Cart Settings › Columns); price.onSale: false hides the struck regular price |
sku | string | — | The SKU, in the SKU column and, with columns.name.sku, under the name |
imageUrl | string | — | The image in the Image column; without it the cell stays empty at its width |
onSplit | () => void | — | With columns.quantity.split and a quantity above 1, a Split link under the quantity calls this |
picking | boolean | false | Widens the quantity column for WCPOS v2's split-by-item stepper; pass the same value as CartColumnHeads' picking, as the Cart does while its picker is on |
locale | string | — | Locale for money formatting |
className | string | — | Override row styles |