Repository navigation
Incorrect Backorder Quantity Handling When Adding Same Product to Cart With Different Custom Options - #3447
Incorrect Backorder Quantity Handling When Adding Same Product to Cart With Different Custom Options#3447rutvik-monpara wants to merge 2 commits into
Conversation
…s with different custom options
|
@magento run all tests |
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 |
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]; |
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) ✗ |
|
Hello @rutvik-monpara, We appreciate your contribution! Since we haven't received a response from you for an extended period, we are closing this PR for now. Whenever you're ready to resume work on this, please feel free to reopen it or request us to do so. We'll be more than happy to assist you. Thanks once again! |
Fixed Issues
Manual testing scenarios
Contribution checklist (*)