Use this when the business wants its own page design around the catalog. The rows come from the storefront API at render time, so a new product or a price change shows without editing the page.
If the person only wants a working shop, the built-in store is quicker: switch on Storefront and it serves /store, /store/<product slug> and /store/checkout with no page to build. Ask which they want.
Ask first
- Built-in store, or their own designed pages? This skill is the second.
- Which products? All, one category, one tag, one brand, a price range. How many per page.
- The URLs. The list page's slug (e.g.
shop; notstorewhen Storefront is on, it owns that URL) and the product page. The product page is namedproduct(step 4). - What each card and the product page show: image, name, price, a short description, a sale price.
- Variants? Products with sizes or colours need choices on the product page (see What it can't do yet).
Steps
1. Site settings: switch on the storefront
In the site's Site Features, switch on Storefront (e-commerce in site.data.features). Without it the cart drawer isn't on the page, cart.toggle does nothing, and the cart button is hidden.
Hands on: the site name.
Check: repo_find on site: data.features includes e-commerce (or a { "feature": "storefront" } row that isn't enabled: false).
Stop: switching on the storefront adds a cart and a checkout to the live site. Ask before turning it on.
2. Storefront: the products are ready
The list shows what GET /storefront/products returns. A product is left out when data.hide is true, or when the site has a region and the product isn't sold there. Each product a page shows needs:
| Field | Why |
|---|---|
name, price | shown and added to the cart |
image or images[0].url | the card picture |
slug | the product page finds it by slug. Unique per product, or only one is reachable. |
status: "available", available: true | what the store treats as for sale |
Fix gaps in the product records themselves (see Product with variants), never in the page.
Hands on: the filter that picks the products (e.g. {"category":"tasers"}), and one product slug to test with.
Check: call_appengine GET /storefront/products with that filter (ps=5) returns the products you expect.
3. Build Studio: the shop page
Create it as in Build a website page step 3 (full document in screens[0].html, mirrored in html). The list is a container with data-source="product.list" and one card marked data-bind-each:
<main id="shop">
<h1>Shop</h1>
<section class="grid" data-source="product.list"
data-source-payload='{"category":"{{$query.category}}","limit":24,"page":"{{$query.page}}"}'>
<article class="card" data-bind-each>
<a data-bind-attr-href="'/product?slug=' + data.slug">
<img data-bind-attr-src="data.image" data-bind-attr-alt="data.name">
<h3 data-bind="data.name"></h3>
</a>
<span data-bind="data.price" data-format="currency"></span>
<button data-action="cart.add" data-payload="this">Add to cart</button>
</article>
</section>
<p><span data-bind="catalogTotal"></span> products</p>
</main>| Piece | What it does |
|---|---|
data-source-payload | the filters: category / categories, tag / tags, brand, price ("10-50"), minPrice, maxPrice, and limit, page, sort, sortType. A value that comes out empty (no ?category= in the URL) is left out, so the same page lists everything. Any other key filters on a product attribute ("color":"red"). |
data-bind-each | the card, repeated once per product; inside it data.* is that product |
data-payload="this" on cart.add | adds that product: its id, sku, name, price and image are taken from the row. The cart shows its own "Item added to cart" toast. |
catalogTotal | how many products match, set by the list call |
A link to the product is an expression: data-bind-attr-href="'/product?slug=' + data.slug". Writing data-bind-attr-href="/product?slug={{data.slug}}" sets no link at all.
Category links are plain links: <a href="/shop?category=tasers">Tasers</a>. Paging is <a href="/shop?page=2">.
A search box is a keyword filter fed from page state: "keyword":"{{kw}}" in the payload, and a box that writes it: <input oninput="appmint.state.set('kw', this.value)">. The list fetches again whenever kw changes. See The AppMint JS engine on a page.
Put a cart button in the shared header rather than on this page: <button data-action="cart.toggle">Cart <span data-bind="cart.count" data-format="parentheses"></span></button> (see Shared header and footer).
Hands on: the shop page's id and URL.
Check: open the page in a browser: one card per product, each with its image, name and formatted price; /shop?category=<one> shows only that category.
4. Build Studio: the product page
Name the page product (slug product). On a page with that name, the site gives each /product?slug=… its own title, description, canonical URL and product data for search engines; on any other name every product shares the page's title.
<main id="pdp">
<section data-source="product.get" data-source-payload='{"slug":"{{$query.slug}}"}'>
<img data-bind-attr-src="data.image" data-bind-attr-alt="data.name">
<h1 data-bind="data.title || data.name"></h1>
<p data-bind-html="data.description"></p>
<span data-bind="data.price" data-format="currency"></span>
<button data-action="cart.add" data-payload="this">Add to cart</button>
</section>
</main>product.gettakesslug,skuor the record id and returns one product, so there is nodata-bind-each; the section itself is the product.- Inside a
product.getsection,data-payload="this"is the loaded product, so the same button as the shop card works. If you spell the line out as JSON instead, put text fields in with{{$json:data.name}}(no quotes around it), never"{{data.name}}": a name with a"in it breaks the JSON and the click fails.unitPriceis the price the line carries. data-bind-htmlis not sanitized. Bind it only to descriptions the business wrote.
Hands on: the product page's id.
Check: open /product?slug=<the test slug>: the right product shows, the browser title is the product's name, and one click on Add to cart makes the header count go up by one.
5. Check the cart and checkout
Open the cart from the header: the line shows the product, its quantity and price, and the total. To list the cart on a page of your own, loop over the cart state: <ul data-loop="cart.items"><li data-bind-each><span data-bind="name"></span> × <span data-bind="quantity"></span></li></ul> and <span data-bind="cart.total" data-format="currency"></span>.
Follow the drawer's checkout button to /checkout and stop at the payment step.
Stop: don't pay for a test order on a live site. Payment and order emails are real. Remove the test line from the cart afterwards.
When it's done
Tell the person: the shop page and product page URLs, which products the shop lists and how its filters work, that the storefront is on, and that the cart and checkout were tried up to payment. Open both pages on the site.
What it can't do yet
- Variant choices are page code. Option prices are added to the base price on the page, and the cart line needs both
attributes(the chosen values, e.g.{"Size":"L"}, for display and separate lines) andoptions([{"name":"size","value":"L"}], which the server prices from). That is Page settings JavaScript, not attributes; see Configurable products. Never pass the product's ownattributeslist to the cart; it breaks the cart drawer. wm-storefront-product-controlneeds its product as adata-productJSON attribute on a published page, and its Add to cart only fires anadd-to-cartevent for page code to handle.product.relatedworks (data-source="product.related" data-source-payload='{"id":"{{$query.slug}}","limit":4}'), butproduct.categoriescame back empty on the test site even with categorised products, so list category links by hand.
Don'ts
- Don't make your own page at
/storewhile Storefront is on; the store takes that URL. - Don't copy product names or prices into the page HTML. Bind them, so the page follows the catalog.
- Don't use
Number(),MathorparseInt()in bindings; usedata-format. - Don't add a cart button on a site without Storefront or Rental.
- Don't place a real order to test.