Skip to content

feat(content): name the product cards whose price changed in the catalog in Before you publish - #1664

Merged
gkhngyk merged 4 commits into
ansvisor:mainfrom
cihan-gyk:feature/shopping-card-price-check
Oct 28, 2026
Merged

gkhngyk merged 4 commits into
ansvisor:mainfrom
cihan-gyk:feature/shopping-card-price-check

Conversation

@cihan-gyk

Copy link
Copy Markdown
Collaborator

Summary

Follow-up from #1610 (item 4): Before you publish names the product cards whose price changed in the catalog.

Stacked on #1663 (one price rule), which sets the price a card should show now. This PR's own commits: 4a45572 and 6c8ad72.

A product card's price is written when it goes in, by hand or in the agent's grid, and stays. Before you publish checked the stock and refusals of the products a page links, but not the prices its cards show.

  • getShoppingCheck reads each product's current price, as a card would show it (bestInStock, priceText).
  • readPage collects the product cards in the page's HTML blocks, each with the price it shows (the editor's own card markup).
  • shoppingLinks compares them and returns prices: each card of a product that still sells whose price isn't the catalog's now, one per product.
  • These cards are left alone:
    • a card without a price;
    • a product that no longer sells (it's already listed to remove);
    • a product whose price wasn't read.
  • Before you publish shows its own row next to Shopping links, for example: "2 product cards show an old price", then "Summit: $199.00 on the page, $179.00 now".
  • After a pre-push review fix (6c8ad72), the row says how to fix it: "A card keeps the price it was put in with. To show today's, replace the card: delete it and add the product again (Add › Products)." The editor guide says the same.

priceText moves to lib/content/shopping-path.ts so the server action can use it; _shopping-path.tsx re-exports it.

Limits (follow-ups):

Where people see it: Content Editor › Mark ready, Export or Send → Before you publish. Covered by _before-publish.test.tsx. It wasn't clicked in the browser, because it needs a built shopping path, which the local demo brand doesn't have.

Related issue

Follow-up from #1610's review.

Type of change

  • feat — New feature
  • fix — Bug fix
  • chore — Maintenance / dependencies
  • docs — Documentation only
  • refactor — Code change that neither fixes a bug nor adds a feature
  • test — Adding or updating tests

How to test

  1. cd web && npx vitest run "src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_before-publish.test.tsx" src/lib/content/shopping-check.test.ts src/lib/actions/shopping-path.test.ts
  2. On a shop draft with a shopping path: put a product in as a card, then change its variant's price in the catalog. Before you publish lists the card with the page's price and the price now.

Checklist

  • Branch follows the naming convention (feature/, fix/, chore/, docs/) — see CONTRIBUTING.md
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/)
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR

Full checks were run once, in one tree with this batch's six follow-up branches merged (#1653, #1654 and the four PRs of this batch):

  • server format, lint and npm test: 249 files, 3,356 tests passed;
  • web format, lint (0 errors), typecheck, vitest (445 files, 4,350 tests) and build: all pass.

A pre-push review was done, and its findings for this branch are fixed.

🤖 Generated with Claude Code

cihan-gyk and others added 3 commits October 28, 2026 05:09
…t stock, then its lowest price there

Follow-ups from ansvisor#1607 (items 1 and 4).

One variant rule. The agent's grid and what the agent is told
(shopping-links.js withOffer) take the price of the best stock first, in
stock before low stock, then the lowest price there. The path's offer
(shopping-path.js offerOf) and a card put in by hand (getProductsForBlock)
took the cheapest variant in stock whatever its stock, so a product with an
in-stock $199 variant and a low-stock $149 one showed $149 by hand and $199
from the agent. All three now pick with one rule: bestInStock in the new
server/src/lib/catalog/offer.js, mirrored in web/src/lib/content/
shopping-path.ts.

A sale price alone. A variant with a sale price and no price showed no
price at all. priceAmount (the same two files) now takes the sale price
when there's no price; a price of 0 is still none, and a sale price above
the price still isn't a sale. The server's card text (shopping-blocks.js
priceText), the agent's offer line and price spellings, and the editor's
priceText all read it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…log in Before you publish

Follow-up from ansvisor#1610 (item 4). A product card's price is written when it
goes in, by hand or in the agent's grid, and stays. Before you publish
checked the stock and refusals of the products a page links, not the
prices its cards show.

- getShoppingCheck reads each product's price now, as a card would show
  it: its best stock's variant (bestInStock), priceText.
- readPage collects the product cards in the page's HTML blocks, each with
  the price it shows (the editor's own card markup, product-block.ts).
- shoppingLinks compares them: a card of a product that sells whose price
  isn't the catalog's now, each product once (`prices`). A card without a
  price, a product that no longer sells (listed to remove already) or one
  whose price wasn't read is left alone.
- Before you publish shows a row of its own beside Shopping links: "2
  product cards show an old price", each with the page's price and the
  price now ("no price" when the catalog has none), and to put the product
  in again to show today's.

priceText moves to lib/content/shopping-path.ts so the server action can
use it; _shopping-path.tsx re-exports it. Stacked on
fix/shopping-one-price-rule: the price now is that branch's rule.

Only the products the shopping path checks are compared: a card put in by
hand of a product outside the path isn't read here.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ugh Add › Products

Before you publish's old-price line said to put the product in again
through "Insert › Products", but the menu is Add › Products, and it
didn't say to delete the old card: the check lists every card whose price
doesn't match, so a card left in place keeps the warning. It now reads
"To show today's, replace the card: delete it and add the product again
(Add › Products)." The editor guide says the same.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mintlify

mintlify Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit 1afbc63.

Approve preview

@gkhngyk gkhngyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, with follow-ups.

What I checked:

  • Own change. 4a45572 and 6c8ad72 on top of #1663 (9b8fc88). They apply cleanly on main plus #1663's squash. Merged with the branch instead, they conflict in three files, because #1663's changes would come in twice. So this PR goes in after #1663 is squashed and main is merged into it. With #1662 it has the same one-sentence docs conflict as #1663.
  • The price now is bestInStock over every in-stock variant, refused ones included, ordered by id. That's how the card (getProductsForBlock) and the agent's grid (withOffer) pick it, so a card put in today isn't flagged. It's read only for a product in the path whose state is ok.
  • The cards. readPage reads a.ansvisor-product inside HTML blocks only. Its first span is the price in both the editor's and the API's markup, and the test builds the card with the editor's own productBlockHtml. A card is matched to its product by the same hrefKey as the links. Cards without a price, products that no longer sell, products whose price wasn't read, and products outside the path are left alone. Each product is listed once.
  • The row is a check, so it informs and doesn't block. It's shown only when a card is listed. "no price now" covers a product that lost its price.
  • Speed. One pass over the blocks and the cards. No new regex.
  • Tests. On this head the shopping-check, rules, action and Before you publish tests pass, and so do the editor's folder and lib/content (1,396 tests; three page.test.tsx tests timed out under the full run's load and pass alone). Breaking each piece on purpose fails a test: ignoring the cards, comparing a product that no longer sells or one that wasn't read, listing a product twice, reading no cards, and dropping the row.

Follow-ups (low):

  1. Tests that don't fail yet:

    • The editor not passing page.cards to shoppingLinks (_draft-editor.tsx): page.test.tsx still passes, because the Before you publish test is given prices directly.
    • A card with no price, for a product that has one now, being compared.
    • readPage taking any link inside an HTML block as a card.

    One case each would pin them.

  2. "Changed in your catalog" isn't always true. A card put in by hand since #1607, under the old "cheapest in stock" rule, shows as an old price until it's replaced, even if the catalog never changed. That's what the description means by "once". The row's fix (replace the card) is still right. Only the guide's sentence "whose price has changed in your catalog since they went in" overstates it. The guide could also say that only the shopping path's products are checked.

  3. Compared as text. The card's price was formatted in the browser (by hand) or on the API (the grid), and today's price is formatted in the server action. That's the same for USD, EUR and GBP, but a runtime's ICU data could differ for a rarer currency. Comparing the amount and the currency instead of the text would rule that out.

Before the API deploy: web only. The check runs in a server action on catalog_variants columns that are already on prod, so it works on merge. Cards on prod today come only from Add › Products, since the agent's grid needs the API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants