Skip to content

feat(backorders): BACK-472 render backorder quantity prompt for complex products on PDP#2618

Merged
bc-apostoliuk merged 1 commit intomasterfrom
BACK-472/backorder-quantity-prompt-complex-products
Mar 2, 2026
Merged

feat(backorders): BACK-472 render backorder quantity prompt for complex products on PDP#2618
bc-apostoliuk merged 1 commit intomasterfrom
BACK-472/backorder-quantity-prompt-complex-products

Conversation

@bc-apostoliuk
Copy link
Contributor

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

Jira: BACK-472

What/Why?

Screen.Recording.2026-03-02.at.14.05.42.mov

The "quantity on backorder" prompt on the PDP only worked for simple products. For complex products (with variants), availableOnHand and availableForBackorder were injected once at page load and never updated when a different variant was selected, causing incorrect backorder calculations.

This PR:

  • Injects availableToSell, showBackorderAvailabilityPrompt, and the i18n backorder message (products.quantity_backordered) into the JS context
  • Adds updateBackorderContext() to refresh variant-level inventory values (availableOnHand, availableForBackorder, availableToSell) from the optionChange API response on every variant selection
  • Falls back to data.stock (and the displayed stock DOM value) when available_on_hand is not present in the API response
  • Recalculates the backorder message inside updateView() after every variant change
  • Replaces the hardcoded backorder text with the i18n string
  • Respects the merchant's showBackorderAvailabilityPrompt setting
  • Preserves backward compatibility for simple products

Rollout/Rollback

Standard deployment. Rollback by reverting the PR if needed.

Testing

  1. Simple product with backorder enabled:

    • Navigate to PDP of a simple product with stock tracking and backorder enabled
    • Set quantity > on-hand stock → verify "{X} will be backordered" message appears with correct count
    • Set quantity <= on-hand stock → verify message hides
  2. Complex product (with variants) with backorder enabled:

    • Navigate to PDP of a product with multiple variants, stock tracking, and backorder enabled
    • Select a variant → verify stock level updates
    • Set quantity > on-hand stock for selected variant → verify backorder message appears with correct count
    • Switch to a different variant with different stock → verify backorder message recalculates correctly
    • Set quantity <= on-hand stock → verify message hides
  3. Merchant settings:

    • With "Quantity on backorder" display disabled → verify message never appears
    • With inventory display set to "Don't Show" → verify stock container and backorder message are hidden
  4. Edge cases:

    • Quantity exactly equal to on-hand → no backorder message
    • Quantity exceeding availableToSell → no backorder message (OOS)

Made with Cursor

…ex products on PDP

Update the backorder quantity message to work for complex products
(with variants) in addition to simple products. When a variant is
selected, inventory context (availableOnHand, availableForBackorder,
availableToSell) is refreshed from the optionChange API response so
the backorder calculation uses the correct variant-level values.

Changes:
- Inject availableToSell, showBackorderAvailabilityPrompt, and the
  i18n backorder message into the JS context
- Add updateBackorderContext() to refresh inventory values on variant
  change, with fallback to data.stock when available_on_hand is absent
- Recalculate the backorder message inside updateView() after every
  variant selection
- Use the i18n string (products.quantity_backordered) instead of
  hardcoded text
- Read displayed stock from the DOM as fallback for onHand to handle
  products where available_on_hand is not populated
- Respect showBackorderAvailabilityPrompt merchant setting
- Preserve backward compatibility for simple products

Made-with: Cursor
@bc-apostoliuk bc-apostoliuk force-pushed the BACK-472/backorder-quantity-prompt-complex-products branch from 08c8e6a to fee238f Compare March 2, 2026 12:16
@bc-apostoliuk bc-apostoliuk merged commit 00f15f9 into master Mar 2, 2026
1 check passed
@bc-apostoliuk bc-apostoliuk deleted the BACK-472/backorder-quantity-prompt-complex-products branch March 2, 2026 15:07
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.

3 participants