woocommerce-gateway-paypal-express-checkout icon indicating copy to clipboard operation
woocommerce-gateway-paypal-express-checkout copied to clipboard

PayPal buttons do not show if query string is stripped

Open jessepearson opened this issue 5 years ago • 2 comments

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

  1. Add snippet below in functions.php
  2. Make sure PP checkout is set to show on checkout and on single products
  3. View a product, no PP buttons will not appear due to JS error
  4. Add product to cart, proceed to checkout
  5. 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

jessepearson avatar May 27 '20 13:05 jessepearson

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 avatar May 27 '20 14:05 jorgeatorres

@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.

jessepearson avatar May 27 '20 14:05 jessepearson