woocommerce-gateway-paypal-express-checkout
woocommerce-gateway-paypal-express-checkout copied to clipboard
PayPal buttons do not show if query string is stripped
Affected customers
9761161-hc
Describe the bug
If something (like a caching plugin) strips the query string off of the paypal_sdk JS link, then PP returns an error and the PP buttons do not appear on the product page, cart or checkout.
Is it possible to pass the data in the same data the way the REST API works in WordPress? Meaning in/this/type/of/format :)
To reproduce
- Add snippet below in functions.php
- Make sure PP checkout is set to show on checkout and on single products
- View a product, no PP buttons will not appear due to JS error
- Add product to cart, proceed to checkout
- Select PP to pay, buttons will not appear due to JS error
add_filter( 'script_loader_src', function( $src ) {
$output = explode( '?', $src );
return $output[0];
});
Screenshots
Image Link: https://d.pr/i/tj64yD
Image Link: https://d.pr/i/czpM0j
Expected behavior
For the buttons to show if something is is aggressively removing query strings.
Environment (please complete the following information):
- WordPress Version = 5.4.1
- WooCommerce Version = 4.1.1
- PayPal (Express) Checkout Plugin Version = 2.0.1
Hi @jessepearson!
Thanks for the report. We will have to look into this, but using the query string is literally the documented way to configure the PayPal scripts (see https://developer.paypal.com/docs/checkout/reference/customize-sdk/#query-parameters).
We might be able to do something about it, though, probably by lazy loading the PayPal API using JS. Just adding it here as a comment so that we look into that possibility.
@jorgeatorres Ya, I think the filter I added above is pretty aggressive. I believe most plugins that remove query strings from resources are just targeting version numbers, but it's always possible that some may be doing it this way.