Skip to content

fix(backorders): BACK-637 respect unlimited_backorder on PDP for simple and complex products#2671

Merged
bc-apostoliuk merged 2 commits into
masterfrom
BACK-637
Jun 8, 2026
Merged

fix(backorders): BACK-637 respect unlimited_backorder on PDP for simple and complex products#2671
bc-apostoliuk merged 2 commits into
masterfrom
BACK-637

Conversation

@bc-apostoliuk

@bc-apostoliuk bc-apostoliuk commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

What?

Screen.Recording.2026-06-03.at.13.04.43.mov

Fixes PDP backorder rendering when a product is configured with unlimited backorder. Previously, both simple and complex products on the storefront PDP ignored unlimited_backorder = true and clamped calculations by available_for_backorder / available_to_sell, which caused:

  • Complex product: when shopper qty exceeds on-hand, the backorder availability prompt, "N will be backordered" message, and backorder message did not render — but the qty could still be added to cart.
  • Simple product: when shopper qty exceeds on-hand, the PDP showed a "max purchasable is X" error with a disabled Add to Cart button, even though cart and checkout accept the unlimited backorder qty.

This change mirrors the picklist (complex product) logic in picklist-backorder.js: when unlimited_backorder === true, the available_for_backorder and available_to_sell caps are treated as Infinity, so the backorder UI renders correctly and the Add to Cart cap is lifted.

Files changed:

  • templates/components/products/product-view.html — inject unlimitedBackorder from product.unlimited_backorder into the JS context.
  • assets/js/theme/common/product-details-base.js:
    • updateBackorderContext — pick up data.unlimited_backorder from the /remote/v1/product-attributes/{id} variant-change response so the flag updates when the shopper switches variants.
    • updateQtyBackorderedMessage — when unlimited, drop the available_for_backorder clamp on the backordered quantity and treat withinSellLimit as always true so the "N will be backordered" message renders.
    • updateAddToCartForQty — when unlimited, treat availableToSell as Infinity so the qty cap and "max purchasable" message are not applied.
    • updateBackorderPrompt — when unlimited, treat availableForBackorder / availableToSell as Infinity so the backorder availability prompt is shown.
  • CHANGELOG.md — Draft entry added.

Requirements

  • CHANGELOG.md entry added (required for code changes only)

Tickets / Documentation

Screenshots (if appropriate)

N/A — UI behavior change verified by selecting a qty above on-hand on a product configured with unlimited backorder.

Test plan

  • On a storefront with a simple product configured with unlimited_backorder = true: select a qty above on-hand stock on the PDP. Expect the backorder availability prompt, the "N will be backordered" message, and the backorder message to render. Add to Cart stays enabled and no "max purchasable" error is shown.
  • On a storefront with a complex (variant) product configured with unlimited_backorder = true: select a variant, set qty above on-hand. Expect the same backorder UI to render. Switch to a variant without unlimited backorder and confirm the normal caps reapply.
  • Regression check: product with finite available_for_backorder and available_to_sell still renders the existing capped backorder message and disables Add to Cart when qty exceeds ATS.

🤖 Generated with Claude Code


Note

Medium Risk
Changes PDP purchase and backorder messaging logic; mis-handling could allow over-ordering or hide limits for finite backorder products, but scope is limited to the new flag and mirrors existing picklist behavior.

Overview
Respects unlimited_backorder on the PDP so storefront behavior matches cart/checkout when a product allows unlimited backorder.

product-view.html now injects unlimitedBackorder into the JS context. In product-details-base.js, when that flag is true, available_for_backorder and available_to_sell are treated as unbounded (Infinity) for backorder qty messaging, the availability prompt, and Add to Cart quantity limits. updateBackorderContext also reads unlimited_backorder from variant/product-attribute API responses so the flag stays correct after option changes.

Draft CHANGELOG entry documents the fix.

Reviewed by Cursor Bugbot for commit 874349b. Bugbot is set up for automated code reviews on this repo. Configure here.

…le and complex products

When `unlimited_backorder = true`, the PDP backorder calculations now
skip the `available_for_backorder` and `available_to_sell` caps so that:

- the "N will be backordered" quantity message renders for any qty
  above on-hand stock;
- the backorder availability prompt renders;
- the Add to Cart button is no longer disabled with a "max purchasable"
  error when quantity exceeds available_to_sell.

Mirrors the existing picklist (complex product) backorder logic in
picklist-backorder.js. The `unlimited_backorder` flag is injected from
the Stencil product context on initial render and refreshed from the
variant-attributes endpoint response on variant change.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@bc-apostoliuk bc-apostoliuk requested a review from a team as a code owner June 3, 2026 10:03

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit a09a906. Configure here.

Comment thread assets/js/theme/common/product-details-base.js
# Conflicts:
#	CHANGELOG.md
#	assets/js/theme/common/product-details-base.js
@bc-apostoliuk bc-apostoliuk merged commit daef06d into master Jun 8, 2026
9 checks passed
@bc-apostoliuk bc-apostoliuk deleted the BACK-637 branch June 8, 2026 14:20
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.

7 participants