woocommerce / woocommerce-gateway-paypal-express-checkout

59 stars 64 forks source link

Wrong locale function 'get_paypal_locale()' #721

Closed AmeenJalali closed 4 years ago

AmeenJalali commented 4 years ago

Describe the bug

Our website is based in Australia. When we changed the landing page from login (PayPal account) to billing (Non-PayPal account), after clicking on PayPal smart button on the checkout page, we redirect to PayPal link like:

sandbox.paypal.com/checkoutnow?locale.x=en_US&fundingSource=paypal&sessionID=f542d1d07e_mdsdjy6mzm&buttonSessionID=83529fa81e_msd26mjc6mja&env=sandbox&fundingOffered=paypal&logLevel=warn&sdkMeta=eyJ1cmwiOiJod2Rwczo123123asdaxxvYmplY3RzLfNvbS9hcGkvY2hs2tvdXQuan23D&uid=f0e347a45a&version=4&token=EC-9S631129131J&xcomponent=1#/checkout/guest

If you see, you can find out the locale.x set to en_US. This causes the default country on the PayPal website set to the USA and not Australia. Because get_paypal_locale() function always returns US country as locale parameter in the URL and it's very bad for customers. They are forced to change the country.

To reproduce

  1. Change your woocommerce store location
  2. Add products to cart, go to checkout and try to pay with PayPal
  3. You can see the default country set to the USA and local.x parameter in the URL set to en_US

Expected behavior

I expected when our store based in Australia, after clicking on the PayPal button, the default location on the PayPal website set to Australia, not the USA.

Environment (please complete the following information):

james-allan commented 4 years ago

Hi there @AmeenJalali.

What is your site's language set to in your WordPress settings?

That function you linked to, get_paypal_locale() only returns en_US if your store is based in the US, which doesn't apply to you, or your site's language isn't one that PayPal supports.

When I checked on my local site, I found that if I set it to English (Australia), then en_AU is sent to PayPal.

Screen Shot 2020-05-01 at 4 44 28 pm

Could you confirm what your site language is set to? You can find that setting in Settings > General from your WordPress dashboard.

AmeenJalali commented 4 years ago

Thanks for helping @james-allan, it works properly!

mattallan commented 4 years ago

Thanks @AmeenJalali, glad to hear it's working now :) Closing this out