magento2: Guest can't use Paypal Express in cart
Preconditions (*)
- Magento 2.3.2
- Paypal Express checkout enabled
- Paypal In-Context mode enabled
- Paypal Show in cart enabled
- Paypal guest checkout enabled
Steps to reproduce (*)
- Guest user, first time on the shop (no localStorage or session)
- Add any product to cart
- Click Paypal button to start express checkout
Expected result (*)
- Popup to login to Paypal opens
Actual result (*)
- Error message
To check out, please sign in with your email address.appears and checkout is not possible
The problem can also be reproduced by clearing local storege in cart and refreshing the page.
The issue is here. customerData.get('cart') is empty when this code runs for guests or users with no localStorage.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 23 (8 by maintainers)
I resolved it by adding a subscriber to cart section if initial value is undefined. If it is undefined it means localstorage is probably empty and sections did not finish loading yet. In
magento/module-paypal/view/frontend/web/js/in-context/button.js: