Home›Support›English Support›[Resolved] 'woocommerce_product_query_tax_query' not taking effect in second language
[Resolved] 'woocommerce_product_query_tax_query' not taking effect in second language
This thread is resolved. Here is a description of the problem and solution.
Problem: The client was unable to filter out products from a specific category on the front page using WPML for their multilingual WooCommerce site. The provided code snippet worked in the default language (Czech) but not in the translated language (English). Solution: We pointed out that the English category had only one product translated, and for the filter to take effect in the second language, the client needed to translate the rest of the products. If this solution doesn't look relevant, please open a new support ticket.
This is the technical support forum for WPML - the multilingual WordPress plugin.
Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.
Languages: English (English )Spanish (Español )German (Deutsch )
Timezone: America/Lima (GMT-05:00)
Hello,
I would like to offer to have a closer look at the problem and request temporary access (wp-admin and FTP) to the website to investigate this issue further.
You can find the required fields below the comment section when you log in to leave the next reply. The information you provide is private, which means only you and I can see and access it.
IMPORTANT
Please be sure to make a backup copy of the website and database before allowing us access.
If you can't see the wp-admin / FTP fields, your post and website credentials are set as PUBLIC. DO NOT publish the data unless you see the required wp-admin / FTP fields.
I may have to install a plugin called "All In One WP Migration" to make a copy of the website where I can investigate the issue further.
However, I would also be very grateful if you could provide a staging site or copy of the website from your server yourself for this purpose.
If you have any questions about creating such a staging site, you can consult your hosting provider. Just take note that WPML should be registered on this site again.
If you are unable to provide such a copy of the site for testing, please let me know on this ticket.
The private response form looks like this: hidden link
Next time you reply, click "I still need assistance."
Video: hidden link
Please note that we are obliged to request this information individually on each ticket. We may not access any access information not specifically submitted on this ticket in the private response form.
I would like to add there is also issue with filtering product on translated version of woocommerce. With default language filters are present but in translated language are not. Please see attached screenshots. Filters based on tags works, filters based on attributes does not.
I'm not sure, but WP implements attributes in same way as categories, so it might be releated to my issue mentioned above.
that is residue of my previous debugging of this issue. My goal is to hide product category "Merchandise" on front page in both languages.
This is my original approach:
// Hide products in specific category on front page
add_filter( 'woocommerce_product_query_tax_query', 'exclude_products_from_fp', 10, 2 );
function exclude_products_from_fp( $tax_query, $query ) {
if( is_front_page() ){ // this also might be a issue, is '/en' considered as frontpage?
$tax_query[] = array(
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => array('merchandise'), // 'merchandise-en' also doesn't work on english lang
'operator' => 'NOT IN',
);
}
return $tax_query;
}