docs
/
AI skills

Product with variants

Add a product that comes in sizes and/or colours as real variants, each with its own SKU, price and stock, put it in a category, and give it a shipping weight and box size so it can be shipped.

A variant is not a note in the description. In Appmint, it is a variation on the product: each one has its own SKU, price and stock, and the shopper picks it at checkout. Variations are built from the product's attributes (size, colour), which point to reusable attribute definitions.

Ask first

  • Name, price and a short description. A base SKU too, if they have one (otherwise one is made from the name).
  • The options: which sizes and which colours, exactly as they should show.
  • Price per variant: does any variant cost more (e.g. XXL +$2)?
  • Stock per variant: how many of each.
  • Category: which one (an existing category, or a new one).
  • Shipping: the packed weight and the box size (length × width × height) of one unit. Ask for the units (lb/oz/kg/g, in/cm). Never guess these: wrong sizes buy wrong labels.
  • Publish now or keep as a draft?

Steps

1. Attributes: size and colour

The product's attributes refer to attribute records (sf_attribute) by name. Find size and colour (or whatever they're called in this shop). If one is missing, create it with its options. If one exists but lacks an option the person asked for, add the option and keep the existing ones.

Hands on: the attribute names and the options to use. Check: each attribute record lists every option needed.

2. Products: the product and its variants

Create the product (sf_product). Saving it is a plain record create, the same write as the product editor's Save. Set these fields:

FieldValue
name, description, pricethe base product
skuthe base SKU (made from the name if left empty)
attributes[{ name: 'size', options: [{label, value}…] }, { name: 'colour', options: [...] }]
variationsone per combination: { sku, price, stock, options: [{ name, label, value }…] }
parcel{ weight, weightUnit, length, width, height, dimensionUnit }
statusdraft unless the person said to publish

The server makes variation SKUs: every save fills one that is blank (or carries the old undefined prefix) as <product SKU>-<option value>-… in upper case (LIN-TEE-7BCN + size s → LIN-TEE-7BCN-S), and Generate Variants asks the server for the same (POST storefront/products/variations). A SKU you type is kept, so set your own only when the business already has SKUs (appengine storefront/product-variations.ts). Give each variation its own stock. Fill in price only where it differs from the base price.

stock on the product and its variations is the product's own number until stock is kept in Inventory. As soon as any of its SKUs has a stock row there, Inventory owns the figures: after every stock movement the server copies the totals onto the product and each variation (stock, locationStock), the editor shows them read-only, and a stock written here is overwritten. Ask whether they use Inventory, and if so set stock there: see Stock levels.

Hands on: the product's sk. Check: open it (/product?openId=<sk>). Under Variants, there is one row per combination with the right SKU, price and stock. Under Shipping, the weight and box size are filled in.

3. Categories: put it in a category

A product's categories are on the record, in post.categories (the category's slug name), not in its data.

  1. If the category doesn't exist, add it with POST storefront/categories and { name, title, parent? }. Adding a category that already exists does no harm.
  2. Set the product's categories with POST repository/update-partial/sf_product/<sk> and { "post.categories": ["<category name>"] }. Keep any categories it already had.

Generic AI record updates only write the product's data, so they report success without setting the category. Use the call above.

Check: read the product back. Its post.categories (not data.post) contains the category.

4. Publish (only when told)

Stop: publishing puts the product in the shop for customers to buy. Show the name, the price, the variants with their stock, and the category, and wait for yes. Then publish it from the product editor, in the person's view, so they see it go live.

Listing it on Google Shopping or social channels is a separate step that needs its own yes.

When it's done

Tell the person:

  • the product, its base price and SKU;
  • each variant with its SKU, price and stock;
  • the category;
  • the shipping weight and box size;
  • whether it is live or still a draft.

Open the product on its own screen.