• I have a suggestion related to this WordPress module.

    Woocommerce uses transient data in shortcodes like [products]. The problem is that this transient data is not invalidated when language is changed.

    So, if I open the site (let’s say it is in DE lang) the page is displayed correctly. But if I change the lang (lets’ say to EN), all the content is in EN but the content provided by the [products] is still in DE.

    So I came up with this solution: add lang parameter to the shortcode query. This forces Woocommerce to build a different transient record in db for each language.

    add_action( 'woocommerce_shortcode_products_query', 'add_lang_attribute_to_wc_shortcode_products_query' );
    function add_lang_attribute_to_wc_shortcode_products_query($atts){
    	if (function_exists('qtranxf_getLanguage')) {
    		$atts['lang'] = qtranxf_getLanguage();
    	}
    	return $atts;
    }
    • This topic was modified 7 years, 6 months ago by adriandance.
  • The topic ‘Add lang attribute to Woocommerce shortcode query’ is closed to new replies.