Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to Merge guest quote items to customer quote(if customer log in) by magento 2 rest API #24808

Closed
sangeetajain opened this issue Oct 1, 2019 · 11 comments
Labels
Component: Api Use with concrete module component label E.g. "Component: Api" + "Catalog" Component: Quote Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release

Comments

@sangeetajain
Copy link

sangeetajain commented Oct 1, 2019

Preconditions (*)

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.

Steps to reproduce (*)

  1. Create a customer
  2. Log out from customer account
  3. Add any product to cart
  4. Try to merge quotes via API
Authorization -"Bearer {user-token}"
PUT {URL}/rest/V1/guest-carts/{guest-card-id}
Body: 
{
  "customerId": {customer id},
  "storeId": {store id}
}

Expected result (*)

200 OK
true

Actual result (*)

getting error : "The customer can't be assigned to the cart because the customer already has an active cart."
Screenshot from 2019-10-02 13-18-36

@m2-assistant
Copy link

m2-assistant bot commented Oct 1, 2019

Hi @sangeetajain. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

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?

  • yes
  • no

@magento-engcom-team magento-engcom-team added the Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed label Oct 1, 2019
@engcom-Charlie engcom-Charlie self-assigned this Oct 2, 2019
@m2-assistant
Copy link

m2-assistant bot commented Oct 2, 2019

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: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label 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 branch

    Details- 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.

@magento-engcom-team magento-engcom-team added Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed and removed Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed labels Oct 2, 2019
@engcom-Charlie engcom-Charlie added Component: Api Use with concrete module component label E.g. "Component: Api" + "Catalog" Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release labels Oct 2, 2019
@ghost ghost unassigned engcom-Charlie Oct 2, 2019
@magento-engcom-team
Copy link
Contributor

✅ 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.

@magento-engcom-team magento-engcom-team added the Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development label Oct 2, 2019
@ivanko-dev ivanko-dev self-assigned this Oct 2, 2019
@m2-assistant
Copy link

m2-assistant bot commented Oct 2, 2019

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:

  • 1. Add/Edit 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 branch

    Details- 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.


@sangeetajain
Copy link
Author

Hello Team,
Is there any update regarding this issue...?

@sangeetajain
Copy link
Author

Hello Team,
Is there any update regarding this issue...?

@engcom-Charlie
Copy link
Contributor

Hello @sangeetajain !
Fix in progress as you can see in #24862 .

@ghost ghost unassigned ivanko-dev Oct 29, 2019
@magento-engcom-team magento-engcom-team added the Fixed in 2.3.x The issue has been fixed in 2.3 release line label Oct 30, 2019
@magento-engcom-team
Copy link
Contributor

@dimaportenko
Copy link

I created a workaround from the above fix for versions < 2.3.4. https://github.com/troublediehard/plab-cartsmergefix

@anowarsadata
Copy link

What need to do for work with magento 2.3.3

@ghost
Copy link

ghost commented Feb 22, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Api Use with concrete module component label E.g. "Component: Api" + "Catalog" Component: Quote Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

No branches or pull requests

6 participants