• I want to have Woocommerce product categories (=menu) and products identical in all languages.

    The menu consists of product categories. My preferred URL setting is “get language by content”, because i like the idea of unchanged URLs throughout the shop (although this does’nt make much sense in respect of search engines…)

    Unfortunately the “glueing” plugin WooPoly doesn’t work with this setting as the author states.

    With this setting the language is kept within a cookie.

    The default language is German. When i switch to english and click on a product category, the language is kept, but as soon as i view a product page (which is a custom post type), the language falls back to the default language.

    Is there any way to keep the language in english ? Does this setup make sense ?

    Thanks, guys !

    • This topic was modified 8 years, 1 month ago by jayhall. Reason: text formatting
Viewing 1 replies (of 1 total)
  • Thread Starter jayhall

    (@jayhall)

    after looking into
    /wp-content/plugins/polylang/frontend/choose-lang-content.php
    and
    /wp-content/plugins/polylang/frontend/choose-lang-content.php

    if found the solution by setting the preferred language (if not the default language) a second time based on the pll_language cookie value.

    Luckily the author has provided a filter hook:

    
    function bs_set_preferred_lang_by_cookie($lang) {
    	if (isset($_COOKIE['pll_language'])) {
    		if($_COOKIE['pll_language']=='en'){
    			global $polylang;
    			$lang = $polylang->get_preferred_language();
    		}
        }
        return $lang;
    }
    add_filter('pll_get_current_language', 'bs_set_preferred_lang_by_cookie');
    

    If you opt for “set language by content” and don’t want to translate / synchronize identical categories and posts (like me) then this seems to be the way to go. I haven’t tried it yet but theoretically this should work, even if your content doesn’t have assigned any language at all.

    The drawback of my solution is that when i itend to switch back to the default language, i have to go back to the home page in order to reset the preferred language.

Viewing 1 replies (of 1 total)
  • The topic ‘Polylang and WooCommerce – Language gets lost on Product Pages’ is closed to new replies.