diff --git a/changelog.txt b/changelog.txt index cdf2d81cc..b2439866a 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,8 @@ *** WooCommerce Tax Changelog *** += 3.2.3 - 2025-xx-xx = +* Fix - Resolved issue where shipping features were incorrectly loading when in tax-only mode for some installations. + = 3.2.2 - 2025-11-10 = * Add - Allow round tax at subtotal level, instead of rounding per line. * Add - Allow calculating taxes for VAT countries without providing ZIP. diff --git a/classes/class-wc-connect-help-view.php b/classes/class-wc-connect-help-view.php index 0a90b5cd3..c7ae6361b 100644 --- a/classes/class-wc-connect-help-view.php +++ b/classes/class-wc-connect-help-view.php @@ -298,7 +298,7 @@ public function page() { ); // Shipping related. - if ( ! WC_Connect_Loader::is_wc_shipping_activated() && '1' !== WC_Connect_Options::get_option( 'only_tax' ) ) { + if ( WC_Connect_Loader::should_load_shipping_features() ) { do_action( 'enqueue_wc_connect_script', 'wc-connect-admin-test-print', diff --git a/readme.txt b/readme.txt index 5aadc3396..f664fea67 100644 --- a/readme.txt +++ b/readme.txt @@ -70,6 +70,9 @@ This plugin relies on the following external services: == Changelog == += 3.2.3 - 2025-xx-xx = +* Fix - Resolved issue where shipping features were incorrectly loading when in tax-only mode for some installations. + = 3.2.2 - 2025-11-10 = * Add - Allow round tax at subtotal level, instead of rounding per line. * Add - Allow calculating taxes for VAT countries without providing ZIP. diff --git a/woocommerce-services.php b/woocommerce-services.php index 56000cabc..b3deeb06c 100644 --- a/woocommerce-services.php +++ b/woocommerce-services.php @@ -915,7 +915,7 @@ public function load_admin_dependencies() { add_action( 'admin_notices', array( $this, 'render_schema_notices' ) ); // Don't register settings if only_tax mode. - if ( '1' === WC_Connect_Options::get_option( 'only_tax' ) ) { + if ( ! self::should_load_shipping_features() ) { return; } @@ -950,7 +950,7 @@ public function attach_hooks() { $this->paypal_ec->init(); // Only register shipping label-related logic if WC Shipping is not active. - if ( ! self::is_wc_shipping_activated() && '1' !== WC_Connect_Options::get_option( 'only_tax' ) ) { + if ( self::should_load_shipping_features() ) { add_action( 'rest_api_init', array( $this, 'wc_api_dev_init' ), 9999 ); $this->init_shipping_labels(); @@ -1950,10 +1950,22 @@ public static function has_only_tax_functionality() { $result = ( WC_Connect_Jetpack::is_connected() && '1' === WC_Connect_Options::get_option( 'only_tax' ) ) || ( ! WC_Connect_Jetpack::is_connected() && ! self::_has_any_labels_db_check() ); - // Allow tests to override this functionality + // Allow tests to override this functionality. return apply_filters( 'wc_connect_has_only_tax_functionality', $result ); } + /** + * Checks whether shipping-related functionality and views should be loaded. + * + * Shipping features should only be loaded when the WooCommerce Shipping plugin + * is not active and the site is not restricted to tax-only functionality. + * + * @return bool True if shipping features should be loaded, false otherwise. + */ + public static function should_load_shipping_features(): bool { + return ! self::is_wc_shipping_activated() && ! self::has_only_tax_functionality(); + } + public function maybe_rename_plugin( $plugins ) { $plugin_basename = 'woocommerce-services/woocommerce-services.php';