fix(pdp): respect available_to_sell for backorderable products (BACK-633)#2659
Open
bc-apostoliuk wants to merge 2 commits into
Open
fix(pdp): respect available_to_sell for backorderable products (BACK-633)#2659bc-apostoliuk wants to merge 2 commits into
bc-apostoliuk wants to merge 2 commits into
Conversation
…633) - Hide Sold Out alert and variant message when stock is 0 but backorder is available - Keep Add to Cart enabled when available_to_sell > 0 - Disable Add to Cart and show "maximum purchasable quantity" message when qty exceeds available_to_sell - Fetch variant-level data on initial load for all products (not just simple ones) so backorder state is known before any option change - Use context.availableToSell as fallback when BCData lacks variant-level numeric fields Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
# Conflicts: # CHANGELOG.md
bc-maksym-konohorov
approved these changes
May 14, 2026
animesh1987
approved these changes
May 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Fixes a set of bugs on the PDP where the storefront treated
out_of_stockas a hard stop, ignoring whether the variant is still purchasable via backorder (available_to_sell > 0). The Sold Out alert was being shown, the Add to Cart button was being disabled, and the variant message box was rendering "Out of stock" even though the customer could still buy the product via backorder.Technical details:
templates/components/products/add-to-cart.html): The Sold Out alert now renders only when the product is out of stock ANDproduct.available_to_sellis falsy. Rewritten as nested{{#if}}/{{#unless}}block helpers (the prior{{#and product.out_of_stock (unless product.available_to_sell)}}subexpression didn't evaluate as expected in paper-handlebars).templates/components/products/product-view.html): InjectedquantityMaxMessagefromproducts.quantity_maxso the JS can render the localized over-limit message.assets/js/theme/common/product-details-base.js:updateDefaultAttributesForOOSandupdateWalletButtonsViewcomputecanSell = data.instock || data.available_to_sell > 0, falling back tocontext.availableToSellwhen the response object lacks a numericavailable_to_sell(initialBCData.product_attributesreturnsnullfields).toggleSoldOutAlert(canSell)hides both the template-rendered Sold Out alert and the variant message box (.productAttributes-message) when the variant can still be sold; shows the alert when it cannot.updateAddToCartForQty(qty)disables Add to Cart and populates the variant message box with "The maximum purchasable quantity is X" when the requested qty exceedsavailable_to_sell; re-enables and clears the message when qty drops back within range. Uses adata-qty-limitattribute so it doesn't stomp on other variant messages (e.g. invalid combo warnings).context.availableToSell > 0, so the template-rendered alert disappears before JS receives variant data.assets/js/theme/common/product-details.js: The initialproductAttributes.optionChangecall now fires for all products, not just simple ones. This ensures variant-levelavailable_to_sell/instockare fetched on page load for variant products too, so the Sold Out alert/message state is correct before any user interaction.Requirements
Tickets / Documentation
Screenshots (if appropriate)
Screen.Recording.2026-05-14.at.14.47.08.mov
🤖 Generated with Claude Code