Skip to content

Incorrect Backorder Quantity Handling When Adding Same Product to Cart With Different Custom Options - #3447

Closed
rutvik-monpara wants to merge 2 commits into
magento:developfrom
rutvik-monpara:fix-issue-3446
Closed

rutvik-monpara wants to merge 2 commits into
magento:developfrom
rutvik-monpara:fix-issue-3446

Conversation

@rutvik-monpara

Copy link
Copy Markdown

Fixed Issues

  1. Fixes Incorrect Backorder Quantity Handling When Adding Same Product to Cart With Different Custom Options #3446: Incorrect Backorder Quantity Handling When Adding Same Product to Cart With Different Custom Options

Manual testing scenarios

  1. Create a simple product with custom options.
  2. Set product stock quantity to 10.
image
  1. Enable backorders: Catalog > Products > Advanced Inventory > Backorders > Allow Qty Below 0 and Notify Customer
  2. On frontend, add the same product to the cart twice, each with a different custom option. For each cart item, set quantity to 20.

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds are green)

@engcom-Hotel
engcom-Hotel self-requested a review January 21, 2026 09:25
@engcom-Hotel

Copy link
Copy Markdown
Collaborator

@magento run all tests

@engcom-Hotel engcom-Hotel left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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];

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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) ✗

@engcom-Hotel engcom-Hotel moved this from Ready for Review to Changes Requested in Inventory - Pull Request Progress Jan 21, 2026
@engcom-Hotel

Copy link
Copy Markdown
Collaborator

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect Backorder Quantity Handling When Adding Same Product to Cart With Different Custom Options

2 participants