Pwa-studio: [bug]: Call mergeCarts to merge guest and customer carts within customer login

Created on 25 Feb 2020  Â·  11Comments  Â·  Source: magento/pwa-studio

Describe the bug
PWA does not merge guest and customer shopping carts.

To reproduce
1. As guest, add any product into shopping cart
2. Login as a registered customer
3. Verify customer's shipping cart

Actual result
Customer's cart does not contain a product which has been added into guest's cart

Expected behavior
Customer's cart contains a product which has been added into guest's cart.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

Possible solutions
We should use mergeCarts mutation query if visitor has added a product as guest into shopping cart and then it logs in as a customer.

Please complete the following device information:

  • Device [e.g. iPhone6, PC, Mac, Pixel3]:
  • OS [e.g. iOS8.1, Windows 10]:
  • Browser [e.g. Chrome, Safari]:
  • Browser Version [e.g. 22]:
  • Magento Version:
  • PWA Studio Version:
  • NPM version npm -v:
  • Node Version node -v:


Please let us know what packages this bug is in regards to:

  • [ ] venia-concept
  • [ ] venia-ui
  • [ ] pwa-buildpack
  • [ ] peregrine
  • [ ] pwa-devdocs
  • [ ] upward-js
  • [ ] upward-spec
  • [ ] create-pwa
bug help wanted

Most helpful comment

Hello @awilcoxa
Sorry, I didn't see your last message.
I am going to finish with it on this weekend.

All 11 comments

on logout should retain current functionality with a cart reset.

Good candidate for community, moving top of backlog for additional prioritization and detail.

@atwixfirster - you get first dibs on this issue if you want it, otherwise we'll open it up to the community during the sync meeting tomorrow. We're making an effort to guide contributors more, so some notes on that change.

Implementation Guidance

  • packages/venia-ui/lib/components/SignIn/signIn.js

    • Add merge cart mutation and pass to talon, please just make a private member, don't add to /queries directory. ie. const MERGE_CART_MUTATION = <query>. We're codifying a standard for this, but we're not 100% set on colocation.

  • packages/peregrine/lib/talons/SignIn/useSignIn.js

    • Init mergeCart mutation and call directly in handleSubmit (no need to create a redux action for this, we're starting to migrate away from that pattern in the scope of data fetching)

    • removeCart/createCart calls can stay since they handle updating the context, which we wouldn't want to include in this scope. Keep a copy of the guest cart id, validate it has items, then call the merge mutation.

Hi, @tjwiebell !

Thank you so much for your notices but I am not a good in PWA coding. Let's pass this one to a strong PWA contributor.

Thanks again!

Hello, folk.
I am going to fix it.
Please assign it to me.
Thank you in advance.

@andrewbess any updates?

Hello @awilcoxa
Sorry, I didn't see your last message.
I am going to finish with it on this weekend.

Hello @awilcoxa.
I am waiting for the decision about my PR on the backed part.
I think it is a lousy way to alter it later.
The GraphQL for merging carts looks like incorrect. It doesn't use Magento best practices.
I don't understand why it has been changed from the correct code to incorrect.
Please take a look at commits below.
Correct commit (IMHO)
https://github.com/magento/graphql-ce/pull/950
Incorrect commit that changes previous (IMHO)
https://github.com/magento/magento2/commit/f19f7270ecc066a32226fbd90f6eda6f18b22c61
I'll create the PR today evening.

@andrewbess - Was tracking the progress of that issue and saw GraphQL closed as expected behavior and intended design. Are we unblocked to implement this into PWA, or is there still an issue with that endpoint that prevents the functionality we're after?

Unassigned and moved back to prioritized, needs a contributor

@larsroettig sorry I saw this issue is not assigned and I have completed and gave PR.
Then I realised you started working on this.

No problem I have not invested so much time on it. Next time I would better
to write a the ticket.
Thank you for the contribution 🎉🎉.

best regards,

Lars

christopher daniel notifications@github.com schrieb am Fr. 1. Mai 2020 um
22:02:

@larsroettig https://github.com/larsroettig sorry I saw this issue is
not assigned and I have completed and gave PR.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/magento/pwa-studio/issues/2190#issuecomment-622542500,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ABILLGV3G265PUK5R6DDU3DRPMTG3ANCNFSM4K3DVEUQ
.

>

https://www.techdivision.com

TechDivision GmbH

Spinnereiinsel 3a
83059 Kolbermoor
Lars Röttig
Software Engineer

Magento Community Maintainer
Magento 2 Certified Professional Developer
Zend Certified PHP Engineer

Tel +49 8031 2210 55 0

Fax +49 8031 2210 55 22

Geschäftsführer: Josef und Stefan Willkommer, Tim Wagner
Handelsregister Nr. HRB 17123, Amtsgericht Traunstein
UStID gemäß § 27 a Umsatzsteuergesetz: DE249664276

Was this page helpful?
0 / 5 - 0 ratings