woocommerce / woocommerce-paypal-payments

https://wordpress.org/plugins/woocommerce-paypal-payments/
GNU General Public License v2.0
62 stars 48 forks source link

Latest version (2.9.4) appears to break third-party shipping plugins #2807

Open normana10 opened 3 days ago

normana10 commented 3 days ago

Describe the Bug

Updated to the latest version of this plugin recently (2.9.4) and all my shipping options disappeared (using the EasyShip plugin)

Dug around and found that EasyShip is registering it's shipment method like so (appears standard):

add_action( 'woocommerce_shipping_init', array( $this, 'init' ) );

That seems fine, except that hook is being added as part of this hook:

add_action( 'init', 'initialize_easyship' );

It appears some sneaky init hook that's being registered with a priority of 5 is initializing WC_Shipping before EasyShip has even had the chance to register it's shipping method

If I change the init hook above to the following I get my shipping methods back (my solution for them moment seeing as EasyShip hasn't updated the plugin in well over a year. I also shot them an email asking if they could make the same change upstream, but given it hasn't been updated in a year, I won't be surprised if they don't):

add_action( 'init', 'initialize_easyship', 4 );

I can also confirm that disabling the PayPal plugin brings back the shipment methods

I've got a backtrace of the init hook that's registered at a priority 5 that's prematurely initializing WC_Shipping (or at least I assume it would be pre-mature for WC_Shipping to be initialized by 5 of init, but maybe not shrug)

Backtrace:

#0 /home/<redacted>/public_html/wp-content/plugins/woocommerce/includes/class-wc-shipping.php(68): WC_Shipping->__construct()
#1 /home/<redacted>/public_html/wp-content/plugins/woocommerce/includes/class-wc-shipping-zone.php(165): WC_Shipping::instance()
#2 /home/<redacted>/public_html/wp-content/plugins/woocommerce-paypal-payments/modules/ppcp-axo/services.php(263): WC_Shipping_Zone->get_shipping_methods()
#3 /home/<redacted>/public_html/wp-content/plugins/woocommerce-paypal-payments/lib/packages/Inpsyde/Modularity/Container/ReadOnlyContainer.php(71): WooCommerce\PayPalCommerce\Axo\AxoModule::WooCommerce\PayPalCommerce\Axo\{closure}(Object(WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Container\ReadOnlyContainer))
#4 /home/<redacted>/public_html/wp-content/plugins/woocommerce-paypal-payments/modules/ppcp-axo-block/services.php(41): WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Container\ReadOnlyContainer->get('...')
#5 /home/<redacted>/public_html/wp-content/plugins/woocommerce-paypal-payments/lib/packages/Inpsyde/Modularity/Container/ReadOnlyContainer.php(71): WooCommerce\PayPalCommerce\AxoBlock\AxoBlockModule::WooCommerce\PayPalCommerce\AxoBlock\{closure}(Object(WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Container\ReadOnlyContainer))
#6 /home/<redacted>/public_html/wp-content/plugins/woocommerce-paypal-payments/modules/ppcp-axo-block/src/AxoBlockModule.php(111): WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Container\ReadOnlyContainer->get('...')
#7 /home/<redacted>/public_html/wp-includes/class-wp-hook.php(324): WooCommerce\PayPalCommerce\AxoBlock\AxoBlockModule->WooCommerce\PayPalCommerce\AxoBlock\{closure}(Object(Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry))
#8 /home/<redacted>/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array)
#9 /home/<redacted>/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#10 /home/<redacted>/public_html/wp-content/plugins/woocommerce/src/Blocks/Integrations/IntegrationRegistry.php(50): do_action('...', Object(Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry))
#11 /home/<redacted>/public_html/wp-includes/class-wp-hook.php(324): Automattic\WooCommerce\Blocks\Integrations\IntegrationRegistry->initialize('')
#12 /home/<redacted>/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array)
#13 /home/<redacted>/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#14 /home/<redacted>/public_html/wp-settings.php(704): do_action('...')
#15 /home/<redacted>/public_html/wp-config.php(99): require_once('...')
#16 /home/<redacted>/public_html/wp-load.php(50): require_once('...')
#17 /home/<redacted>/public_html/wp-blog-header.php(13): require_once('...')
#18 /home/<redacted>/public_html/index.php(17): require('...')

To Reproduce

  1. Install the EasyShip plugin and this PayPal plugin
  2. Attempt to checkout with anything in your cart
  3. Be shown no EasyShip shipping methods

Screenshots

Image

Expected Behavior

I would expect WC_Shipping to not be initialized by 5 of init

Actual Behavior

WC_Shipping is initialized by 5 of init so any plugin-based shipping methods that are registered at the default 10 of init won't appear

Environment

Additional Details

I would debug further but I'm starting to get lost in the PayPal plugin code

But this line here: https://github.com/woocommerce/woocommerce-paypal-payments/blob/trunk/modules/ppcp-axo/services.php#L263

Is the line that is being called during the 5 of init which in turn initializes WC_Shipping

Let me know if you need any more details

Thanks!