Incorrect Backorder Quantity Handling When Adding Same Product to Cart With Different Custom Options#3447
Open
rutvik-monpara wants to merge 2 commits intomagento:developfrom
Open
Incorrect Backorder Quantity Handling When Adding Same Product to Cart With Different Custom Options#3447rutvik-monpara wants to merge 2 commits intomagento:developfrom
rutvik-monpara wants to merge 2 commits intomagento:developfrom
Conversation
…s with different custom options
Collaborator
|
@magento run all tests |
engcom-Hotel
requested changes
Jan 21, 2026
Collaborator
engcom-Hotel
left a comment
There was a problem hiding this comment.
Hello @rutvik-monpara,
Thank you for your report and collaboration!
Please refer to the below review comments and also please cover the PR changes with some automated tests.
Thank you
| private $getBackorderQty; | ||
|
|
||
| /** | ||
| * Product backorder qty's checked |
Collaborator
There was a problem hiding this comment.
The PR introduces instance-level state in service classes, according to the Magento 2 coding guidelines "Services SHOULD be stateless".
| $backorderQty = $this->getBackorderQty->execute($sku, $stockId, $requestedQty); | ||
|
|
||
| if (isset($this->backorderQty[$sku])) { | ||
| $backorderQty -= $this->backorderQty[$sku]; |
Collaborator
There was a problem hiding this comment.
I guess the subtraction logic produces WRONG results.
It subtracts the previously stored backorder qty, resulting in 0 for the second item instead of showing the correct cumulative backorder.
for e.g.
| Call | Scenario | Expected | Actual with this code |
|---|---|---|---|
| 1st | Item A, qty=20, stock=10 | backorder=10 | backorder=10 ✓ (stored: 10) |
| 2nd | Item B, qty=20, stock=10 | backorder=20 (cumulative) | backorder=0 (10-10=0) ✗ |
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.
Fixed Issues
Manual testing scenarios
Contribution checklist (*)