Automattic / woocommerce-services

WooCommerce Services is a feature plugin that integrates hosted services into WooCommerce (3.0+), and currently includes automated tax rates and the ability to purchase and print USPS shipping labels.
GNU General Public License v2.0
108 stars 20 forks source link

Introduce new "wc_services_will_disable_shipping_logic" hook #2775

Closed kallehauge closed 4 months ago

kallehauge commented 4 months ago

Description

We've previously agreed to rely on a hook called wc_services_will_handle_coexistence_with_woo_shipping_and_woo_tax that will return true if both WC Tax and WC Shipping are activated and that all logic in WCS&T will stop working if that's the case, so our individual plugins can take over.

The #2761 PR will force the hook to always be "true" which causes two issues:

  1. It's purely down to a race-condition that we're not blocking both Tax and Shipping from being initiated.
    • _The "bail early" logic is defined in on_plugins_loaded which comes after we force the hook to always be true._
  2. WC Tax will always assume that it can initiate its logic while WCS&T also initiates its tax logic which causes issues.

We should instead add a new filter (wc_services_will_disable_shipping_logic) that represents WCS&T supporting conditionally loading shipping, so WC Shipping can listen for that as well as the pre-existing wc_services_will_handle_coexistence_with_woo_shipping_and_woo_tax condition.

_Note: we could remove wc_services_will_handle_coexistence_with_woo_shipping_and_woo_tax but that would prevent us from being able to have months old versions of WCS&T be able to work with both individual plugins present and it's the only WC Tax specific support WCS&T has right now, so it doesn't make sense to remove it._

Related issue(s)

How to test

_Important! Make sure WC Tax isn't activated when you go through this test to make sure we're testing the new wc_services_will_disable_shipping_logic filter._

Checklist