Skip to content

feat(backorders): BACK-466 render backorder message on PDP#2625

Open
bc-apostoliuk wants to merge 2 commits intomasterfrom
BACK-466/render-backorder-message-pdp
Open

feat(backorders): BACK-466 render backorder message on PDP#2625
bc-apostoliuk wants to merge 2 commits intomasterfrom
BACK-466/render-backorder-message-pdp

Conversation

@bc-apostoliuk
Copy link
Contributor

@bc-apostoliuk bc-apostoliuk commented Mar 19, 2026

Jira: BACK-466

What/Why?

Screen.Recording.2026-03-19.at.19.26.45.mov

Renders a custom backorder message alongside the existing qty-backordered message on the Product Detail Page.

  • backorder_messages list and product.show_backorder_message are injected into the JS context from product-view.html
  • The data-product-backordered row is split into two inner spans: data-qty-backordered-message (existing qty text) and data-backorder-message (new custom message)
  • updateBackorderMessage() looks up backorder_message_id (returned by remote/v1/product-attributes/:productId) in the injected list and renders it only when the qty backordered span is also visible
  • toggleBackorderedContainer() is now driven solely by the qty span, so the row only shows when units are actually being backordered
  • updateBackorderContext() always overwrites backorderMessageId with data.backorder_message_id ?? null to prevent stale IDs from a previous variant bleeding through on variant switches
  • updateBackorderMessage() is called in updateView() (variant changes) and both quantity change handlers (+/- button and keyup)
  • For simple products (no selectable options), an explicit optionChange call is made on page init to fetch backorder_message_id

Rollout/Rollback

Standard deployment. Rollback by reverting the PR if needed.

Testing

  1. Simple product with backorder message configured — load PDP, increment qty past available stock; verify the custom backorder message appears next to "N will be backordered"
  2. Complex product (variants) with per-variant backorder messages — select each variant, increment qty past stock; verify the correct message for each variant is shown
  3. Variant switch — with qty in backorder range, switch variants; verify the message updates to the new variant's message (or clears if the new variant has none) after the API responds
  4. Qty back below threshold — decrement qty below backordered range; verify both the qty message and the custom backorder message disappear together
  5. show_backorder_message = false — verify no custom message renders even when backorder_message_id is set

Made with Cursor

- Inject backorder_messages list and product.show_backorder_message into
  JS context from product-view.html
- Split data-product-backordered row into two spans: one for qty
  backordered message and one for the custom backorder message
- Add updateBackorderMessage() that looks up backorder_message_id in the
  injected list and renders alongside the qty backordered message
- Add toggleBackorderedContainer() driven solely by qty span visibility
  so the row is only shown when units are actually backordered
- Capture backorder_message_id from optionChange API response in
  updateBackorderContext() always overwriting with ?? null to prevent
  stale IDs bleeding across variant switches
- Call updateBackorderMessage() in updateView() and both quantity change
  handlers (button click and keyup)
- For simple products (no options) make an explicit optionChange call on
  page init to fetch backorder_message_id

Made-with: Cursor
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.

5 participants