Warp Matrix demo — a row × column input field for Filament: stock by size and color, prices, permissions. Change anything; the data is reset every hour. warpui.com About Warp Matrix Docs Ask a question Support
Skip to content

Price tiers

Maple Thread sells the Oxford shirt for less when you buy more, and for less again to members and businesses. Each table is one array of prices — [quantity => [customer => price]] — ready for a JSON column. Click “Show what would be saved” to see it.

Prices with cents and a $ sign

->numeric(decimals: 2) takes up to two decimal places and shows them in every cell. ->prefix('$') puts a $ sign in front of each price.

Note: Try it

Type 49.5 in 10+ × Member and leave the cell: it shows 49.50. Type 49.555 and click “Show what would be saved”: a message under the table asks for no more than 2 decimal places.

Prices of the Oxford shirt
Quantity
Retail
Member
1+
10+
50+

Columns in groups

Give ->columns() an array of arrays: the outer keys (Shoppers, Businesses) are written over their columns. Rows can be grouped the same way.

Note: Try it

Look at the top of the table: Retail and Member are under Shoppers, Reseller and Wholesale under Businesses. The saved array has no groups in it — click “Show what would be saved”.

Prices by kind of customer
Quantity
Shoppers Businesses
Retail
Member
Reseller
Wholesale
1+
10+
50+

The average under each column

->totals(rows: false, columns: true) adds a row under the table, and ->totalsUsing('average') makes it the average instead of the sum (a sum of prices means nothing). Also: count, min and max.

Note: Try it

Change 1+ × Retail from $59.00 to $65.00: the average under Retail goes from $54.48 to $56.48 as you type.

Prices with their average
Quantity
Retail
Member
1+
10+
50+
Average $54.48 $49.03