Tally UI

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

PropTypeDefaultDescription
namestringrequiredThe line's name
attributesRecord<string, string>—The variant's chosen options, shown under the name
quantitynumberrequiredThe quantity
unitPriceMoneyrequiredThe unit price
regularUnitPriceMoney—The regular unit price; struck through only when it is above unitPrice in the same currency
lineTotalMoneyrequiredThe line total, shown as given
showPricebooleantrueShows the Price column; pass the same value as CartColumnHeads
quantitySlotReactNode—Replaces the quantity's text, e.g. a LinePopover
priceSlotReactNode—Replaces the unit price's text; the struck regular price stays above it
columnsCartColumnSettings—Which columns show, as CartColumnHeads' columns (v2's Cart Settings › Columns); price.onSale: false hides the struck regular price
skustring—The SKU, in the SKU column and, with columns.name.sku, under the name
imageUrlstring—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
pickingbooleanfalseWidens 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
localestring—Locale for money formatting
classNamestring—Override row styles

Live demo