VariationPicker
VariationPicker lets the cashier pick one value per option group, shows the matched variant's stock and price, and adds it with an Add to Cart button.
Import
import { VariationPicker } from '@tallyui/components';Usage
<VariationPicker
title="T-shirt"
groups={[{ name: 'Size', values: ['S', 'M', 'L'] }]}
variants={variants}
currency="USD"
onAdd={(variant, anyPicks) => addToCart(variant, anyPicks)}
preventOverselling
/>The body of the variations popover, ported from WCPOS v2. It keeps its own picks: values no variant allows with the other picks are dimmed and cannot be pressed. A group whose values total fewer than 15 characters shows as buttons (pressing the picked one again clears it); a longer group shows as a select. Once every group is picked, it shows the matched variant's stock and an Add to Cart button, with the variant's price when it has one in currency, or "Variant not available" when no variant fits. A full match never adds on its own.
Use VariationPicker when you have the product's variants and want the picker to match one and add it. Use ProductVariantPicker when you only need controlled chips: it keeps no state, matches no variant and reports the selection to onSelect.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
title | string | required | The product name, shown above the groups |
groups | VariantOptionGroup[] | required | The option groups to pick from, values in the backend's order |
variants | VariantSummary[] | required | The variants to match the picks against |
currency | string | required | Currency the Add to Cart price is shown in |
onAdd | (variant: VariantSummary, anyPicks: Record<string, string>) => void | Promise<void> | required | Called with the matched variant and the picks for its "Any" groups |
preventOverselling | boolean | false | Disables Add when the matched variant is out of stock |
testID | string | 'variation-popover' | Test id of the root view |
anyPicks holds the picked value for each group the variant has no value in (a WooCommerce "Any" attribute); it is empty when there are none. When onAdd returns a promise, Add stays disabled until it settles.
The stock line uses the stock badge labels: out of stock and backorder are always shown, in stock only with a tracked quantity.