Product page
Versions, pack sizes, price types, extras and stock.
A product holds everything its page needs.
Versions
versions are the product's sizes or colours, one per variant. name is null when the product has only one. Each has its own variantId, sellingPrice, photo (imageUrl, or null for the product's) and stock:
inStock | Meaning |
|---|---|
true | In stock at the branch that fills online orders. |
false | Out of stock: don't let it be added. |
null | The shop doesn't count its stock: always available. |
Pack sizes
sellingUnits are the packs a version is also sold in (a carton of 24, a pack of 10), each with its own id and price. To sell a pack, send its id as sellingUnitId on the order line; quantity then counts packs.
Price types
priceTypes are the prices the shop offers online (Retail, and others such as Wholesale). Each version and pack lists its price at each in prices. Show a picker when there is more than one, and send the picked id as priceListId (leave it out for Retail, whose id is null).
function linePrice(version, { sellingUnitId, priceListId = null }) {
const unit = sellingUnitId
? version.sellingUnits.find((u) => u.id === sellingUnitId)
: version;
const price = unit.prices.find((p) => p.priceListId === priceListId);
return price ? price.sellingPrice : unit.sellingPrice;
}Extras
addonGroups are choices that change the order, such as toppings or a side:
| Field | Meaning |
|---|---|
mode | one: pick one, many: pick any number. |
required | The customer must pick at least one. |
options[].sellingPrice | What the option adds to each item. |
options[].preselected | Picked unless the customer changes it. |
Send the picked option ids as addons on the line. Left out, the preselected ones are used.
Putting it in the cart
A cart line is exactly what an order line takes:
type CartLine = {
variantId: string;
quantity: number;
sellingUnitId?: string;
priceListId?: string;
addons?: string[];
note?: string; // "No onions", up to 200 characters
};Keep the cart in your app (local storage, a store, your own database): the API has no cart of its own. Totals are worked out when you place the order.