To check out, please sign in with your email address. appears and checkout is not possibleThe 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.
Hi @domeglic. 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.
@domeglic 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. Verify that the issue is reproducible on 2.2-develop branch. Details
- Add the comment @magento give me 2.2-develop instance to deploy test instance on Magento infrastructure.
- If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x
[ ] 6. Add label Issue: Confirmed once verification is complete.
[ ] 7. Make sure that automatic system confirms that report has been added to the backlog.
@magento give me 2.3-develop instance
Hi @engcom-Charlie. Thank you for your request. I'm working on Magento 2.3-develop instance for you
Hi @engcom-Charlie, here is your Magento instance.
Admin access: https://i-23761-2-3-develop.instances.magento-community.engineering/admin
Login: admin Password: 123123q
Instance will be terminated in up to 3 hours.
Hello @domeglic ! Thank you for your contribution !
I was trying to reproduce this issue on fresh 2.3-develop instance but i can`t do it ( Popup to login to Paypal opens, purchase was successful) . Maybe i missed some steps ? Can you please share your configuration here ?
Feel free to reopen it in case you have some updates .
Thanks in advance !
I was able to reproduce it on the magento instance you created above when it was up. No other configuration should be necessary.
You can also trigger it by clearing all local storage once in the cart, then refresh the page and click the paypal button.
The problem is that when customer-data.js is initialized it will make async requests to actually retrieve sections data (customer, cart). So using customerData.get("cart") before this request has finished will give back no data
Hi, @domeglic ! I check it on fresh Magento 2.3.2:
Actual result:
No errors
GIF:

If you wont to test in instance you can write "@magento give me 2.3-develop instance" and wait 1 min than bot will give it to you.
Hi @engcom-Charlie. Thank you for your request. I'm working on Magento 2.3-develop instance for you
Hi @engcom-Charlie, here is your Magento instance.
Admin access: https://i-23761-2-3-develop.instances.magento-community.engineering/admin
Login: admin Password: 123123q
Instance will be terminated in up to 3 hours.
You need to go to the actual cart page after adding to cart.
@domeglic , no errors again:

I'm also seeing this issue on 2.3.2 in an Incognito session with no local storage (first attempt only). @domeglic, were you able to resolve?
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:
initialize: function (config, element) {
var cart = customerData.get('cart'),
customer = customerData.get('customer');
this._super();
this.renderPayPalButtons(element);
this.declinePayment = !customer().firstname && !cart().isGuestCheckoutAllowed;
// BEGIN CHANGE
if (cart().isGuestCheckoutAllowed === undefined) {
cart.subscribe(function (updatedCart) {
this.declinePayment = !customer().firstname && !cart().isGuestCheckoutAllowed;
return updatedCart;
}.bind(this));
}
// END CHANGE
return this;
}
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:initialize: function (config, element) { var cart = customerData.get('cart'), customer = customerData.get('customer'); this._super(); this.renderPayPalButtons(element); this.declinePayment = !customer().firstname && !cart().isGuestCheckoutAllowed; // BEGIN CHANGE if (cart().isGuestCheckoutAllowed === undefined) { cart.subscribe(function (updatedCart) { this.declinePayment = !customer().firstname && !cart().isGuestCheckoutAllowed; return updatedCart; }.bind(this)); } // END CHANGE return this; }
^^^ spot on, just found this bug putting a client site live tonight, that solves it. Thanks
Same fix for me, but on product page: Magento_Paypal/js/in-context/product-express-checkout
Thanks!
apparently this was never added to code and just closed??????
Please reopen this issue. Nothing was fixed !
This issue should be re-opened.
I was also able to reproduce on Safari, but I can't reproduce it on Firefox and Chrome.
It's Javascript. The lines of code are not executed in the same order on every browser and or machine, so your 'we cannot reproduce' doesn't mean that the bug doesn't exist.
And in addition to the report; it also happens when the 'in-context' mode is set to no.
How do you get an issue reopened? This issue still exists in 2.3.5-p2. In fact, you can also see this issue if you add a discount code in the cart and then attempt to checkout using the paypal express in context button. The paypal window flashes up, then disappears. You cant checkout unless you refresh the cart page and try again. I don't know how the guys from Magento can't reproduce this. It happens on all 5 Magento 2 sites that I have built so far.
@domeglic - Thanks so much for your fix. It works a treat
Regards
Mark
Same with magento 2.3.5-p1
Most helpful comment
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: