Commit 0ec081d673e for woocommerce
commit 0ec081d673ef00020ad796127bdcbd3770b69b69
Author: Anuj Singh <80690679+Anuj-Rathore24@users.noreply.github.com>
Date: Wed Sep 23 16:55:23 2026 +0530
Fix fatal TypeError in Product Price Filter when using standard tax class (#68999)
Fix fatal TypeError in Product Price Filter for standard tax class
diff --git a/plugins/woocommerce/changelog/68706-fix-price-filter-tax-type-error b/plugins/woocommerce/changelog/68706-fix-price-filter-tax-type-error
new file mode 100644
index 00000000000..ada828e44f3
--- /dev/null
+++ b/plugins/woocommerce/changelog/68706-fix-price-filter-tax-type-error
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Fix fatal TypeError in Product Price Filter when prices are entered excluding tax and displayed including tax with standard tax class.
diff --git a/plugins/woocommerce/src/Internal/ProductFilters/QueryClauses.php b/plugins/woocommerce/src/Internal/ProductFilters/QueryClauses.php
index 2c458ad33e6..d327b4703c9 100644
--- a/plugins/woocommerce/src/Internal/ProductFilters/QueryClauses.php
+++ b/plugins/woocommerce/src/Internal/ProductFilters/QueryClauses.php
@@ -470,6 +470,7 @@ class QueryClauses implements QueryClausesGenerator, MainQueryClausesGenerator {
// We need to adjust the filter for each possible tax class and combine the queries into one.
foreach ( $product_tax_classes as $tax_class ) {
+ $tax_class = (string) $tax_class;
$adjusted_price_filter = $this->adjust_price_filter_for_tax_class( $price_filter, $tax_class );
$or_queries[] = $wpdb->prepare(
'( wc_product_meta_lookup.tax_class = %s AND wc_product_meta_lookup.`' . esc_sql( $column ) . '` ' . esc_sql( $operator ) . ' %f )',
diff --git a/plugins/woocommerce/tests/php/src/Internal/ProductFilters/QueryClausesTest.php b/plugins/woocommerce/tests/php/src/Internal/ProductFilters/QueryClausesTest.php
index 71a544d47e1..ce87f2c2c02 100644
--- a/plugins/woocommerce/tests/php/src/Internal/ProductFilters/QueryClausesTest.php
+++ b/plugins/woocommerce/tests/php/src/Internal/ProductFilters/QueryClausesTest.php
@@ -315,4 +315,26 @@ class QueryClausesTest extends AbstractProductFiltersTest {
wp_delete_term( $term['term_id'], 'product_cat' );
}
}
+
+ /**
+ * @testdox Price clauses adjust for standard tax class when shop displays prices including tax.
+ */
+ public function test_price_clauses_with_tax_inclusive_display(): void {
+ update_option( 'woocommerce_calc_taxes', 'yes' );
+ update_option( 'woocommerce_prices_include_tax', 'no' );
+ update_option( 'woocommerce_tax_display_shop', 'incl' );
+
+ $clauses = $this->sut->add_price_clauses(
+ array(
+ 'where' => '',
+ 'join' => '',
+ ),
+ array(
+ 'min_price' => 20,
+ 'max_price' => 50,
+ )
+ );
+
+ $this->assertStringContainsString( "wc_product_meta_lookup.tax_class = ''", $clauses['where'] );
+ }
}