Fix product attributes lookup data and filter by attribute widget with non-ASCII named attributes (#34432)

This only fixes the classic widget, not the equivalent block.
This commit is contained in:
Néstor Soriano 2022-12-02 09:54:38 +01:00 committed by GitHub
parent fee3e10445
commit b7c5519b41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 4 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Fix handling of non-ASCII product attributes when the attributes lookup table is in use

View File

@ -212,12 +212,13 @@ class Filterer {
{$tax_query_sql['join']} {$meta_query_sql['join']} {$tax_query_sql['join']} {$meta_query_sql['join']}
INNER JOIN {$wpdb->posts} ON {$wpdb->posts}.ID = {$this->lookup_table_name}.product_or_parent_id"; INNER JOIN {$wpdb->posts} ON {$wpdb->posts}.ID = {$this->lookup_table_name}.product_or_parent_id";
$term_ids_sql = $this->get_term_ids_sql( $term_ids ); $encoded_taxonomy = sanitize_title( $taxonomy );
$query['where'] = " $term_ids_sql = $this->get_term_ids_sql( $term_ids );
$query['where'] = "
WHERE {$wpdb->posts}.post_type IN ( 'product' ) WHERE {$wpdb->posts}.post_type IN ( 'product' )
AND {$wpdb->posts}.post_status = 'publish' AND {$wpdb->posts}.post_status = 'publish'
{$tax_query_sql['where']} {$meta_query_sql['where']} {$tax_query_sql['where']} {$meta_query_sql['where']}
AND {$this->lookup_table_name}.taxonomy='{$taxonomy}' AND {$this->lookup_table_name}.taxonomy='{$encoded_taxonomy}'
AND {$this->lookup_table_name}.term_id IN $term_ids_sql AND {$this->lookup_table_name}.term_id IN $term_ids_sql
{$in_stock_clause}"; {$in_stock_clause}";

View File

@ -433,7 +433,7 @@ class LookupDataStore {
$terms = WC()->call_function( $terms = WC()->call_function(
'get_terms', 'get_terms',
array( array(
'taxonomy' => $taxonomy, 'taxonomy' => wc_sanitize_taxonomy_name( $taxonomy ),
'hide_empty' => false, 'hide_empty' => false,
'fields' => 'id=>slug', 'fields' => 'id=>slug',
) )