Commit ab97614b2e8 for woocommerce
commit ab97614b2e8abfe0600f97dd342e6e0a81265c2c
Author: Kaushik Somaiya <92479346+kaushikasomaiya@users.noreply.github.com>
Date: Thu Oct 8 19:34:48 2026 +0530
Add tax settings to the System Status Report (#68643)
* Add tax settings to system status
* Add changelog entry
* Harden additional tax class rendering
* Update V2 system status settings test
* Use effective tax settings in system status
* Match absent tax total display behavior
* Clarify store base country display
diff --git a/plugins/woocommerce/changelog/add-system-status-tax-settings b/plugins/woocommerce/changelog/add-system-status-tax-settings
new file mode 100644
index 00000000000..666e6211dc6
--- /dev/null
+++ b/plugins/woocommerce/changelog/add-system-status-tax-settings
@@ -0,0 +1,4 @@
+Significance: minor
+Type: add
+
+Add Tax settings section to the System Status Report.
diff --git a/plugins/woocommerce/includes/admin/views/html-admin-page-status-report.php b/plugins/woocommerce/includes/admin/views/html-admin-page-status-report.php
index 4a3723755ad..87613bd29c6 100644
--- a/plugins/woocommerce/includes/admin/views/html-admin-page-status-report.php
+++ b/plugins/woocommerce/includes/admin/views/html-admin-page-status-report.php
@@ -7,6 +7,7 @@
use Automattic\Jetpack\Constants;
use Automattic\WooCommerce\Blocks\Utils\CartCheckoutUtils;
+use Automattic\WooCommerce\Enums\{ DefaultCustomerAddress, TaxBasedOn, TaxDisplayMode };
use Automattic\WooCommerce\Utilities\RestApiUtil;
defined( 'ABSPATH' ) || exit;
@@ -31,6 +32,59 @@ $untested_plugins = $plugin_updates->get_untested_plugins( WC()->version, Cons
$active_plugins_count = is_countable( $active_plugins ) ? count( $active_plugins ) : 0;
$inactive_plugins_count = is_countable( $inactive_plugins ) ? count( $inactive_plugins ) : 0;
+$additional_tax_classes_limit = 10;
+$additional_tax_classes = $settings['additional_tax_classes'] ?? array();
+$additional_tax_classes = is_array( $additional_tax_classes ) ? array_values( array_filter( $additional_tax_classes, 'is_string' ) ) : array();
+$displayed_additional_tax_classes = array_slice( $additional_tax_classes, 0, $additional_tax_classes_limit );
+$remaining_additional_tax_classes = max( 0, count( $additional_tax_classes ) - $additional_tax_classes_limit );
+$additional_tax_classes_display = implode( ', ', $displayed_additional_tax_classes );
+
+if ( $remaining_additional_tax_classes ) {
+ $additional_tax_classes_display .= ', ' . sprintf(
+ /* translators: %d: number of additional tax classes not shown. */
+ __( 'and %d more', 'woocommerce' ),
+ $remaining_additional_tax_classes
+ );
+}
+
+$countries = WC()->countries->get_countries();
+$store_base_country = $settings['store_base_country'];
+$store_base_country_display = isset( $countries[ $store_base_country ] ) ? $store_base_country . ' - ' . $countries[ $store_base_country ] : $store_base_country;
+$states = WC()->countries->get_states( $store_base_country );
+$store_base_state = $settings['store_base_state'] ?? '';
+$store_base_state_display = is_array( $states ) && isset( $states[ $store_base_state ] ) ? $states[ $store_base_state ] . ' (' . $store_base_state . ')' : $store_base_state;
+
+$tax_based_on_labels = array(
+ TaxBasedOn::SHIPPING => __( 'Customer shipping address', 'woocommerce' ),
+ TaxBasedOn::BILLING => __( 'Customer billing address', 'woocommerce' ),
+ TaxBasedOn::BASE => __( 'Shop base address', 'woocommerce' ),
+);
+$tax_based_on_display = $tax_based_on_labels[ $settings['tax_based_on'] ] ?? $settings['tax_based_on'];
+
+$shipping_tax_class_labels = array( 'inherit' => __( 'Based on cart items', 'woocommerce' ) ) + wc_get_product_tax_class_options();
+$shipping_tax_class_display = $shipping_tax_class_labels[ $settings['shipping_tax_class'] ] ?? $settings['shipping_tax_class'];
+
+$tax_display_labels = array(
+ TaxDisplayMode::INCLUSIVE => __( 'Inclusive', 'woocommerce' ),
+ TaxDisplayMode::EXCLUSIVE => __( 'Exclusive', 'woocommerce' ),
+);
+$tax_display_shop = $tax_display_labels[ $settings['tax_display_shop'] ] ?? $settings['tax_display_shop'];
+$tax_display_cart = $tax_display_labels[ $settings['tax_display_cart'] ] ?? $settings['tax_display_cart'];
+
+$tax_total_display_labels = array(
+ 'single' => __( 'Single total', 'woocommerce' ),
+ 'itemized' => __( 'Itemized', 'woocommerce' ),
+);
+$tax_total_display = $tax_total_display_labels[ $settings['tax_total_display'] ] ?? $settings['tax_total_display'];
+
+$default_customer_location_labels = array(
+ DefaultCustomerAddress::NO_DEFAULT => __( 'No location by default', 'woocommerce' ),
+ DefaultCustomerAddress::BASE => __( 'Shop country/region', 'woocommerce' ),
+ DefaultCustomerAddress::GEOLOCATION => __( 'Geolocate', 'woocommerce' ),
+ DefaultCustomerAddress::GEOLOCATION_AJAX => __( 'Geolocate (with page caching support)', 'woocommerce' ),
+);
+$default_customer_location = $default_customer_location_labels[ $settings['default_customer_location'] ] ?? $settings['default_customer_location'];
+
// Include necessary WordPress file to use get_plugin_data().
if ( ! function_exists( 'get_plugin_data' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
@@ -780,6 +834,85 @@ if ( 0 < $mu_plugins_count ) :
</tbody>
</table>
+<table class="wc_status_table widefat" cellspacing="0">
+ <thead>
+ <tr>
+ <th colspan="3" data-export-label="Tax Settings"><h2><?php esc_html_e( 'Tax settings', 'woocommerce' ); ?></h2></th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td data-export-label="Enable tax rates and calculations"><?php esc_html_e( 'Enable tax rates and calculations', 'woocommerce' ); ?>:</td>
+ <td class="help"><?php echo wc_help_tip( esc_html__( 'Are tax rates and calculations enabled?', 'woocommerce' ) ); ?></td>
+ <td><mark class="<?php echo esc_attr( $settings['taxes_enabled'] ? 'yes' : 'no' ); ?>"><?php echo $settings['taxes_enabled'] ? esc_html__( 'Enabled', 'woocommerce' ) : esc_html__( 'Disabled', 'woocommerce' ); ?></mark></td>
+ </tr>
+ <tr>
+ <td data-export-label="Prices include tax"><?php esc_html_e( 'Prices include tax', 'woocommerce' ); ?>:</td>
+ <td class="help"><?php echo wc_help_tip( esc_html__( 'Whether product prices are currently treated as including or excluding tax.', 'woocommerce' ) ); ?></td>
+ <td><?php echo $settings['prices_include_tax'] ? esc_html__( 'Inclusive', 'woocommerce' ) : esc_html__( 'Exclusive', 'woocommerce' ); ?></td>
+ </tr>
+ <tr>
+ <td data-export-label="Calculate tax based on"><?php esc_html_e( 'Calculate tax based on', 'woocommerce' ); ?>:</td>
+ <td class="help"><?php echo wc_help_tip( esc_html__( 'The address type WooCommerce uses to calculate tax.', 'woocommerce' ) ); ?></td>
+ <td><?php echo esc_html( $tax_based_on_display ); ?></td>
+ </tr>
+ <tr>
+ <td data-export-label="Shipping tax class"><?php esc_html_e( 'Shipping tax class', 'woocommerce' ); ?>:</td>
+ <td class="help"><?php echo wc_help_tip( esc_html__( 'The tax class WooCommerce uses for shipping.', 'woocommerce' ) ); ?></td>
+ <td><?php echo esc_html( $shipping_tax_class_display ); ?></td>
+ </tr>
+ <tr>
+ <td data-export-label="Rounding"><?php esc_html_e( 'Rounding', 'woocommerce' ); ?>:</td>
+ <td class="help"><?php echo wc_help_tip( esc_html__( 'Whether tax is rounded per line or at subtotal level.', 'woocommerce' ) ); ?></td>
+ <td><?php echo $settings['tax_round_at_subtotal'] ? esc_html__( 'At subtotal level', 'woocommerce' ) : esc_html__( 'Per line', 'woocommerce' ); ?></td>
+ </tr>
+ <tr>
+ <td data-export-label="Additional tax classes"><?php esc_html_e( 'Additional tax classes', 'woocommerce' ); ?>:</td>
+ <td class="help"><?php echo wc_help_tip( esc_html__( 'Additional tax classes configured for products. The list is truncated when more than 10 classes are configured.', 'woocommerce' ) ); ?></td>
+ <td><?php echo $additional_tax_classes_display ? esc_html( $additional_tax_classes_display ) : '<mark class="no">–</mark>'; ?></td>
+ </tr>
+ <tr>
+ <td data-export-label="Display prices in the shop"><?php esc_html_e( 'Display prices in the shop', 'woocommerce' ); ?>:</td>
+ <td class="help"><?php echo wc_help_tip( esc_html__( 'Whether shop prices are displayed including or excluding tax.', 'woocommerce' ) ); ?></td>
+ <td><?php echo esc_html( $tax_display_shop ); ?></td>
+ </tr>
+ <tr>
+ <td data-export-label="Display prices during cart and checkout"><?php esc_html_e( 'Display prices during cart and checkout', 'woocommerce' ); ?>:</td>
+ <td class="help"><?php echo wc_help_tip( esc_html__( 'Whether cart and checkout prices are displayed including or excluding tax.', 'woocommerce' ) ); ?></td>
+ <td><?php echo esc_html( $tax_display_cart ); ?></td>
+ </tr>
+ <tr>
+ <td data-export-label="Price display suffix"><?php esc_html_e( 'Price display suffix', 'woocommerce' ); ?>:</td>
+ <td class="help"><?php echo wc_help_tip( esc_html__( 'Text displayed after product prices.', 'woocommerce' ) ); ?></td>
+ <td><?php echo $settings['price_display_suffix'] ? esc_html( $settings['price_display_suffix'] ) : '<mark class="no">–</mark>'; ?></td>
+ </tr>
+ <tr>
+ <td data-export-label="Display tax totals"><?php esc_html_e( 'Display tax totals', 'woocommerce' ); ?>:</td>
+ <td class="help"><?php echo wc_help_tip( esc_html__( 'Whether tax totals are displayed as a single total or itemized.', 'woocommerce' ) ); ?></td>
+ <td><?php echo esc_html( $tax_total_display ); ?></td>
+ </tr>
+ <tr>
+ <td data-export-label="Tax rates"><?php esc_html_e( 'Tax rates', 'woocommerce' ); ?>:</td>
+ <td class="help"><?php echo wc_help_tip( esc_html__( 'The number of configured tax rates.', 'woocommerce' ) ); ?></td>
+ <td><?php echo esc_html( number_format_i18n( $settings['tax_rate_count'] ) ); ?></td>
+ </tr>
+ <tr>
+ <td data-export-label="Store base country"><?php esc_html_e( 'Store base country', 'woocommerce' ); ?>:</td>
+ <td class="help"><?php echo wc_help_tip( esc_html__( 'The country configured as the store base location.', 'woocommerce' ) ); ?></td>
+ <td><?php echo esc_html( $store_base_country_display ); ?></td>
+ </tr>
+ <tr>
+ <td data-export-label="Store base state"><?php esc_html_e( 'Store base state', 'woocommerce' ); ?>:</td>
+ <td class="help"><?php echo wc_help_tip( esc_html__( 'The state or region configured as the store base location.', 'woocommerce' ) ); ?></td>
+ <td><?php echo $store_base_state_display ? esc_html( $store_base_state_display ) : '<mark class="no">–</mark>'; ?></td>
+ </tr>
+ <tr>
+ <td data-export-label="Default customer location"><?php esc_html_e( 'Default customer location', 'woocommerce' ); ?>:</td>
+ <td class="help"><?php echo wc_help_tip( esc_html__( 'The location WooCommerce assumes for a customer before an address is provided.', 'woocommerce' ) ); ?></td>
+ <td><?php echo esc_html( $default_customer_location ); ?></td>
+ </tr>
+ </tbody>
+</table>
<table class="wc_status_table widefat" cellspacing="0">
<thead>
<tr>
diff --git a/plugins/woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-system-status-v2-controller.php b/plugins/woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-system-status-v2-controller.php
index ada2e354e73..c0c0c845478 100644
--- a/plugins/woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-system-status-v2-controller.php
+++ b/plugins/woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-system-status-v2-controller.php
@@ -15,7 +15,7 @@ use Automattic\WooCommerce\Internal\ProductDownloads\ApprovedDirectories\Registe
use Automattic\WooCommerce\Internal\DataStores\Orders\DataSynchronizer as Order_DataSynchronizer;
use Automattic\WooCommerce\Utilities\{ LoggingUtil, OrderUtil, PluginUtil };
use Automattic\WooCommerce\Blocks\Utils\CartCheckoutUtils;
-use Automattic\WooCommerce\Enums\DefaultCustomerAddress;
+use Automattic\WooCommerce\Enums\{ DefaultCustomerAddress, TaxBasedOn, TaxDisplayMode };
use Automattic\WooCommerce\Internal\Features\FeaturesController;
/**
@@ -628,6 +628,93 @@ class WC_REST_System_Status_V2_Controller extends WC_REST_Controller {
'context' => array( 'view' ),
'readonly' => true,
),
+ 'taxes_enabled' => array(
+ 'description' => __( 'Are tax rates and calculations enabled?', 'woocommerce' ),
+ 'type' => 'boolean',
+ 'context' => array( 'view' ),
+ 'readonly' => true,
+ ),
+ 'prices_include_tax' => array(
+ 'description' => __( 'Are prices treated as including tax?', 'woocommerce' ),
+ 'type' => 'boolean',
+ 'context' => array( 'view' ),
+ 'readonly' => true,
+ ),
+ 'tax_based_on' => array(
+ 'description' => __( 'Address type used to calculate tax.', 'woocommerce' ),
+ 'type' => 'string',
+ 'context' => array( 'view' ),
+ 'readonly' => true,
+ ),
+ 'shipping_tax_class' => array(
+ 'description' => __( 'Tax class used for shipping.', 'woocommerce' ),
+ 'type' => 'string',
+ 'context' => array( 'view' ),
+ 'readonly' => true,
+ ),
+ 'tax_round_at_subtotal' => array(
+ 'description' => __( 'Is tax rounded at subtotal level?', 'woocommerce' ),
+ 'type' => 'boolean',
+ 'context' => array( 'view' ),
+ 'readonly' => true,
+ ),
+ 'additional_tax_classes' => array(
+ 'description' => __( 'Additional tax classes.', 'woocommerce' ),
+ 'type' => 'array',
+ 'context' => array( 'view' ),
+ 'readonly' => true,
+ 'items' => array(
+ 'type' => 'string',
+ ),
+ ),
+ 'tax_display_shop' => array(
+ 'description' => __( 'How prices are displayed in the shop.', 'woocommerce' ),
+ 'type' => 'string',
+ 'context' => array( 'view' ),
+ 'readonly' => true,
+ ),
+ 'tax_display_cart' => array(
+ 'description' => __( 'How prices are displayed during cart and checkout.', 'woocommerce' ),
+ 'type' => 'string',
+ 'context' => array( 'view' ),
+ 'readonly' => true,
+ ),
+ 'price_display_suffix' => array(
+ 'description' => __( 'Price display suffix.', 'woocommerce' ),
+ 'type' => 'string',
+ 'context' => array( 'view' ),
+ 'readonly' => true,
+ ),
+ 'tax_total_display' => array(
+ 'description' => __( 'How tax totals are displayed.', 'woocommerce' ),
+ 'type' => 'string',
+ 'context' => array( 'view' ),
+ 'readonly' => true,
+ ),
+ 'tax_rate_count' => array(
+ 'description' => __( 'Number of configured tax rates.', 'woocommerce' ),
+ 'type' => 'integer',
+ 'context' => array( 'view' ),
+ 'readonly' => true,
+ ),
+ 'store_base_country' => array(
+ 'description' => __( 'Store base country.', 'woocommerce' ),
+ 'type' => 'string',
+ 'context' => array( 'view' ),
+ 'readonly' => true,
+ ),
+ 'store_base_state' => array(
+ 'description' => __( 'Store base state.', 'woocommerce' ),
+ 'type' => 'string',
+ 'context' => array( 'view' ),
+ 'readonly' => true,
+ ),
+ 'default_customer_location' => array(
+ 'description' => __( 'Default customer location.', 'woocommerce' ),
+ 'type' => 'string',
+ 'context' => array( 'view' ),
+ 'readonly' => true,
+ ),
'taxonomies' => array(
'description' => __( 'Taxonomy terms for product/order statuses.', 'woocommerce' ),
'type' => 'array',
@@ -1446,6 +1533,8 @@ class WC_REST_System_Status_V2_Controller extends WC_REST_Controller {
* @return array
*/
public function get_settings() {
+ global $wpdb;
+
// Get a list of terms used for product/order taxonomies.
$term_response = array();
$terms = get_terms( 'product_type', array( 'hide_empty' => 0 ) );
@@ -1468,6 +1557,9 @@ class WC_REST_System_Status_V2_Controller extends WC_REST_Controller {
)
);
+ // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
+ $tax_rate_count = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->prefix}woocommerce_tax_rates" );
+
// Return array of useful settings for debugging.
return array(
'api_enabled' => WC()->legacy_rest_api_is_available(),
@@ -1486,6 +1578,20 @@ class WC_REST_System_Status_V2_Controller extends WC_REST_Controller {
),
true
),
+ 'taxes_enabled' => wc_tax_enabled(),
+ 'prices_include_tax' => wc_prices_include_tax(),
+ 'tax_based_on' => get_option( 'woocommerce_tax_based_on', TaxBasedOn::SHIPPING ),
+ 'shipping_tax_class' => get_option( 'woocommerce_shipping_tax_class', 'inherit' ),
+ 'tax_round_at_subtotal' => 'yes' === get_option( 'woocommerce_tax_round_at_subtotal', 'no' ),
+ 'additional_tax_classes' => WC_Tax::get_tax_classes(),
+ 'tax_display_shop' => get_option( 'woocommerce_tax_display_shop', TaxDisplayMode::EXCLUSIVE ),
+ 'tax_display_cart' => get_option( 'woocommerce_tax_display_cart', TaxDisplayMode::EXCLUSIVE ),
+ 'price_display_suffix' => get_option( 'woocommerce_price_display_suffix', '' ),
+ 'tax_total_display' => get_option( 'woocommerce_tax_total_display', 'single' ),
+ 'tax_rate_count' => absint( $tax_rate_count ),
+ 'store_base_country' => WC()->countries->get_base_country(),
+ 'store_base_state' => WC()->countries->get_base_state(),
+ 'default_customer_location' => get_option( 'woocommerce_default_customer_address', DefaultCustomerAddress::BASE ),
'taxonomies' => $term_response,
'product_visibility_terms' => $product_visibility_terms,
'woocommerce_com_connected' => ConnectionHelper::is_connected() ? 'yes' : 'no',
diff --git a/plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version2/system-status.php b/plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version2/system-status.php
index 21873d81183..369093e6a4e 100644
--- a/plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version2/system-status.php
+++ b/plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version2/system-status.php
@@ -193,7 +193,7 @@ class WC_Tests_REST_System_Status_V2 extends WC_REST_Unit_Test_Case {
}
/**
- * Test to make sure settings response is correct.
+ * @testdox The system status settings response contains the expected values.
*
* @since 3.0.0
*/
@@ -206,7 +206,7 @@ class WC_Tests_REST_System_Status_V2 extends WC_REST_Unit_Test_Case {
$settings = (array) $this->fetch_or_get_system_status_data_for_user( self::$administrator_user )['settings'];
- $this->assertEquals( 17, count( $settings ) );
+ $this->assertEquals( 31, count( $settings ) );
$this->assertEquals( WC()->legacy_rest_api_is_available(), $settings['api_enabled'] );
$this->assertEquals( get_woocommerce_currency(), $settings['currency'] );
$this->assertEquals( $term_response, $settings['taxonomies'] );
diff --git a/plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version3/system-status.php b/plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version3/system-status.php
index 82d57e1cca3..c276aa84ebc 100644
--- a/plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version3/system-status.php
+++ b/plugins/woocommerce/tests/legacy/unit-tests/rest-api/Tests/Version3/system-status.php
@@ -251,7 +251,7 @@ class WC_Tests_REST_System_Status extends WC_REST_Unit_Test_Case {
}
/**
- * Test to make sure settings response is correct.
+ * @testdox The system status settings response contains the expected values.
*
* @since 3.5.0
*/
@@ -264,7 +264,7 @@ class WC_Tests_REST_System_Status extends WC_REST_Unit_Test_Case {
$settings = (array) $this->fetch_or_get_system_status_data_for_user( self::$administrator_user )['settings'];
- $this->assertEquals( 17, count( $settings ) );
+ $this->assertEquals( 31, count( $settings ) );
$this->assertEquals( WC()->legacy_rest_api_is_available(), $settings['api_enabled'] );
$this->assertEquals( get_woocommerce_currency(), $settings['currency'] );
$this->assertEquals( $term_response, $settings['taxonomies'] );
diff --git a/plugins/woocommerce/tests/php/includes/rest-api/Controllers/Version2/class-wc-rest-system-status-v2-controller-test.php b/plugins/woocommerce/tests/php/includes/rest-api/Controllers/Version2/class-wc-rest-system-status-v2-controller-test.php
index 971e07c1be9..90bde4ffc9d 100644
--- a/plugins/woocommerce/tests/php/includes/rest-api/Controllers/Version2/class-wc-rest-system-status-v2-controller-test.php
+++ b/plugins/woocommerce/tests/php/includes/rest-api/Controllers/Version2/class-wc-rest-system-status-v2-controller-test.php
@@ -1,6 +1,8 @@
<?php
declare( strict_types = 1 );
+use Automattic\WooCommerce\Enums\{ DefaultCustomerAddress, TaxBasedOn, TaxDisplayMode };
+
/**
* Tests for WC_REST_System_Status_V2_Controller.
*
@@ -61,4 +63,64 @@ class WC_REST_System_Status_V2_Controller_Test extends WC_REST_Unit_Test_Case {
'Template overridden via wc_get_template filter should appear in overrides'
);
}
+
+ /**
+ * @testdox Should return tax settings used for troubleshooting.
+ */
+ public function test_get_settings_returns_tax_settings(): void {
+ global $wpdb;
+
+ update_option( 'woocommerce_calc_taxes', 'no' );
+ update_option( 'woocommerce_prices_include_tax', 'yes' );
+ update_option( 'woocommerce_tax_based_on', TaxBasedOn::BILLING );
+ update_option( 'woocommerce_tax_round_at_subtotal', 'yes' );
+ update_option( 'woocommerce_tax_display_shop', TaxDisplayMode::INCLUSIVE );
+ update_option( 'woocommerce_tax_display_cart', TaxDisplayMode::EXCLUSIVE );
+ update_option( 'woocommerce_price_display_suffix', 'including tax' );
+ update_option( 'woocommerce_tax_total_display', 'single' );
+ update_option( 'woocommerce_default_country', 'IN:MH' );
+ update_option( 'woocommerce_default_customer_address', DefaultCustomerAddress::GEOLOCATION_AJAX );
+ add_filter( 'wc_tax_enabled', '__return_true' );
+ add_filter( 'woocommerce_prices_include_tax', '__return_false' );
+
+ $tax_class = WC_Tax::create_tax_class( 'Diagnostic rate' );
+ if ( is_wp_error( $tax_class ) ) {
+ $this->fail( 'The diagnostic tax class should be created.' );
+ }
+ $tax_class_slug = $tax_class['slug'];
+ update_option( 'woocommerce_shipping_tax_class', $tax_class_slug );
+
+ // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
+ $tax_rate_count = (int) $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->prefix}woocommerce_tax_rates" );
+ WC_Tax::_insert_tax_rate(
+ array(
+ 'tax_rate_country' => 'IN',
+ 'tax_rate_state' => 'MH',
+ 'tax_rate' => '18.0000',
+ 'tax_rate_name' => 'GST',
+ 'tax_rate_priority' => 1,
+ 'tax_rate_compound' => 0,
+ 'tax_rate_shipping' => 1,
+ 'tax_rate_order' => 1,
+ 'tax_rate_class' => $tax_class_slug,
+ )
+ );
+
+ $settings = $this->sut->get_settings();
+
+ $this->assertTrue( $settings['taxes_enabled'] );
+ $this->assertFalse( $settings['prices_include_tax'] );
+ $this->assertSame( TaxBasedOn::BILLING, $settings['tax_based_on'] );
+ $this->assertSame( $tax_class_slug, $settings['shipping_tax_class'] );
+ $this->assertTrue( $settings['tax_round_at_subtotal'] );
+ $this->assertContains( 'Diagnostic rate', $settings['additional_tax_classes'] );
+ $this->assertSame( TaxDisplayMode::INCLUSIVE, $settings['tax_display_shop'] );
+ $this->assertSame( TaxDisplayMode::EXCLUSIVE, $settings['tax_display_cart'] );
+ $this->assertSame( 'including tax', $settings['price_display_suffix'] );
+ $this->assertSame( 'single', $settings['tax_total_display'] );
+ $this->assertSame( $tax_rate_count + 1, $settings['tax_rate_count'] );
+ $this->assertSame( 'IN', $settings['store_base_country'] );
+ $this->assertSame( 'MH', $settings['store_base_state'] );
+ $this->assertSame( DefaultCustomerAddress::GEOLOCATION_AJAX, $settings['default_customer_location'] );
+ }
}