Forum Replies Created

Viewing 1 replies (of 1 total)
  • Thread Starter korbn

    (@korbn)

    The solution I found is to always display the products of the default language, whatever the current language is. All the products are therefore to be set in the default language.

    add_filter('woocommerce_shortcode_products_query',function($query_args, $atts){
        foreach($query_args['tax_query'] as $key=>$value){
            if($value['taxonomy']=='language'){
                $query_args['tax_query'][$key]['terms'] = DEFAULT_LANGUAGE_ID;
            }
        }
        return $query_args;
    }, 10, 2);

    Of course, you will have to replace DEFAULT_LANGUAGE_ID by your default language id. You can find it in Polylang languages tab (wp-admin/admin.php?page=mlang), by looking the id in the default language edit page (not sure if I am clear enough). This is a number, not a slug (like “en”).

Viewing 1 replies (of 1 total)