Shop: item priority, block sort order and an optional "Sort by" menu

- items.priority (migration + pb_schema.json): Recommended order in Shop
  blocks, higher first, then by name. Set under Services & products, which
  now lists items in that order.
- Shop block: choose its order (Recommended, Most popular, price up/down,
  name) and optionally let visitors re-sort with a "Sort by" menu.
  sortItems() in shared/items.ts is the one place items are ordered.
- Most popular: GET /api/shop/popular returns item ids by units sold in
  paid orders over the last 90 days (ids only, no sales figures).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HA82gWt7pNdAsocjxujY3m
This commit is contained in:
agent 2026-11-04 22:36:50 +00:00
parent 97b1da2433
commit e896fd3c99
14 changed files with 211 additions and 19 deletions

View file

@ -16,6 +16,12 @@ routerAdd('GET', '/api/shop/slots', (e) => {
return e.json(200, shop.bookableTimes($app, { item: query.get('item'), minutes: query.get('minutes'), from: query.get('from'), to: query.get('to') }));
});
// Best sellers first (ids only), for the Shop block's "Most popular" sort.
routerAdd('GET', '/api/shop/popular', (e) => {
const shop = require(`${__hooks}/shop/lib.js`);
return e.json(200, { items: shop.popularItems($app) });
});
routerAdd('GET', '/api/shop/basket/{id}', (e) => {
const shop = require(`${__hooks}/shop/lib.js`);
shop.sweepExpiredHolds($app);