Magento 2.3-develop
If any one is add products in cart by guest and after that login then how it will merge guest cart to customer login cart items by Rest API.
Authorization -"Bearer {user-token}"
PUT {URL}/rest/V1/guest-carts/{guest-card-id}
Body:
{
"customerId": {customer id},
"storeId": {store id}
}
200 OK
true
getting error : "The customer can't be assigned to the cart because the customer already has an active cart."

Hi @sangeetajain. Thank you for your report.
To help us process this issue please make sure that you provided the following information:
Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:
@magento give me 2.3-develop instance - upcoming 2.3.x release
For more details, please, review the Magento Contributor Assistant documentation.
@sangeetajain do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?
Hi @engcom-Charlie. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:
Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.[ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.
[ ] 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.
[ ] 4. Verify that the issue is reproducible on 2.3-develop branchDetails
- Add the comment @magento give me 2.3-develop instance to deploy test instance on Magento infrastructure.
- If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and _stop verification process here_!
[ ] 5. Add label Issue: Confirmed once verification is complete.
[ ] 6. Make sure that automatic system confirms that report has been added to the backlog.
:white_check_mark: Confirmed by @engcom-Charlie
Thank you for verifying the issue. Based on the provided information internal tickets MC-21009 were created
Issue Available: @engcom-Charlie, _You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself._
Hi @ivan-koliadynskyy. Thank you for working on this issue.
Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:
Component: XXXXX label(s) to the ticket, indicating the components it may be related to.[ ] 2. Verify that the issue is reproducible on 2.3-develop branchDetails
- Add the comment @magento give me 2.3-develop instance to deploy test instance on Magento infrastructure.
- If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and _stop verification process here_!
[ ] 3. If the issue is not relevant or is not reproducible any more, feel free to close it.
Hello Team,
Is there any update regarding this issue...?
Hello Team,
Is there any update regarding this issue...?
Hello @sangeetajain !
Fix in progress as you can see in #24862 .
Hi @sangeetajain. Thank you for your report.
The issue has been fixed in magento/magento2#24862 by @ivan-koliadynskyy in 2.3-develop branch
Related commit(s):
The fix will be available with the upcoming 2.3.4 release.
I created a workaround from the above fix for versions < 2.3.4. https://github.com/troublediehard/plab-cartsmergefix
What need to do for work with magento 2.3.3
The fix is working but the merge is not taking into consideration the available quantity of stock items of the products in cart.
At Model\Quote.php, lines 2392 and 2393:
...
$quoteItem->setQty($quoteItem->getQty() + $item->getQty());
$this->itemProcessor->merge($item, $quoteItem);
...
The setQty bypasses any check of availability / eligibility.
Let's say a product has only 1 item in stock, a logged in customer adds it to the cart, then logs out, adds it again as a guest and then logs back in. The merge will result in 2x items of a 1x stock available product, and the checkout will throw an error, forcing the customer to manually adjust qty in cart.