• Hi everyone!

    First of all, thank you Chouby for your awesome plug-in. I have translated, pretty much all of my pages without any troubles, it probably is the first things go as smoothly with WP ??

    However I can’t translate the cart page, the checkout page and the product category page. I have used the Woocommerce Polylang Integration plug in but it doesn’t let me translate these pages. I can’t even translate the ” Add to Cart ” button on the product page.

    Any thoughts on how I could do it?

    Thank you,

    Nicolas

    https://www.ads-software.com/plugins/polylang/

Viewing 15 replies - 1 through 15 (of 34 total)
  • Thread Starter bainiade

    (@bainiade)

    Anyone? That’s a pretty big issue and I can’t find anything online. Thanks

    Plugin Author Chouby

    (@chouby)

    Hi!

    This is a frequent question asked on this support forum. Polylang does not support Woocommerce yet. This is something I am currently working on but don’t expect something in the coming months (Woocommerce is half the size of WordPress!)

    I’ve added the following code as a plugin and I get most of WooCommerce translated. Try it and see if it work for you.

    add_action('pll_language_defined', 'woopll_init');
    
    function woopll_init(){
    
    	if (function_exists('pll_get_post')){ // is Polylang activated?
    
    		add_filter('wc_checkout_params',        'add_language_parameter_to_ajax_url');
            add_filter('wc_cart',                   'add_language_parameter_to_ajax_url');
            add_filter('wc_cart_fragments_params',  'add_language_parameter_to_ajax_url');
            add_filter('wc_add_to_cart_params',     'add_language_parameter_to_ajax_url');
    
    		add_filter('woocommerce_get_cart_page_id', 'pll_woocommerce_get_cart_page_id');
    		add_filter('woocommerce_get_checkout_page_id', 'pll_woocommerce_get_checkout_page_id');
    		add_filter('woocommerce_get_shop_page_id', 'pll_woocommerce_get_shop_page_id');
    		add_filter('woocommerce_get_pay_page_id', 'pll_woocommerce_get_pay_page_id');
    
    		function pll_woocommerce_get_cart_page_id($id) {
    			return pll_get_post(get_option('woocommerce_cart_page_id'));
    		}
    		function pll_woocommerce_get_checkout_page_id($id) {
    			return pll_get_post(get_option('woocommerce_checkout_page_id'));
    		}
    		function pll_woocommerce_get_shop_page_id($id) {
    			return pll_get_post(get_option('woocommerce_shop_page_id'));
    		}
    		function pll_woocommerce_get_pay_page_id($id) {
    			return pll_get_post(get_option('woocommerce_pay_page_id'));
    		}
    
    	}
    
    }
    
    function add_language_parameter_to_ajax_url($woocommerce_params){
    
    	if(pll_current_language() !== pll_default_language()){
    		$woocommerce_params['ajax_url'] = add_query_arg('lang', ICL_LANGUAGE_CODE, $woocommerce_params['ajax_url']);
    	}
    
    	return $woocommerce_params;
    }
    Thread Starter bainiade

    (@bainiade)

    Hey Chouby, that’s already pretty awesome what you did with Polylang!

    Leemon, thanks for the code! I’m a total amateur when it comes to codes. Where does it goes in wordpress?

    Thank you so much!

    You can try to add the code to the functions.php file in your theme.

    bainiade, I made a plugin with the code. You can download it from here (click the red DOWNLOAD link) and install it in your /plugins folder:

    https://pastebin.com/5vVwFGJG

    Thread Starter bainiade

    (@bainiade)

    Hi Leemon, Thanks for your help! I have upload and installed the plug in and here’s what I got :

    Fatal error: Cannot redeclare pll_woocommerce_get_cart_page_id() (previously declared in /home/wp_h9hh36/bainiade.com/wp-content/plugins/woocommerce-polylang-integration/woocommerce-polylang-integration.php:21) in /home/wp_h9hh36/bainiade.com/wp-content/plugins/WOOPOLY.php_/WOOPOLY.php on line 25

    ” WooPoly” is how I renamed your plug in btw.

    Do you think it is because the Woocommerce polyland integration plugin is installed as well?

    Let me know what you think.

    This looks prospecting!

    Any idea on how to “translate” the product category pages as well?

    In my installation where the shop uses an optional language [GB] everything works fine despite of the product categories.

    The generated URLs for the product categoris point to the [GB] domain where nothing is shown.

    Manually altering the URL to the default language I get my content displayed.

    Thanks for any help!

    bainiade, I renamed the plugin and all its functions to not clash with the Woocommerce Polylang integration plugin:

    https://pastebin.com/LRsnY6D8

    Thread Starter bainiade

    (@bainiade)

    Hi Leemon,

    Thanks, but I still the fatal error message… I don’t know why but that’s frustrating!

    Fatal error: Cannot redeclare pll_woocommerce_get_cart_page_id() (previously declared in /home/wp_h9hh36/bainiade.com/wp-content/plugins/woocommerce-polylang-integration/woocommerce-polylang-integration.php:21) in /home/wp_h9hh36/bainiade.com/wp-content/plugins/WOOPOLY.php_/WOOPOLY.php on line 25

    OliverHamburg : I translated the category pages with the WooCommerce Polylang Integration plug in. Just go to categories when the plug in is installed and it lets you translate the categories just like a normal page.

    This refers to my yesterday’s post on the problem displaying product categories.

    I have got it working by removing the tax_query from the query object.

    The query object came with

    ["tax_query"]=>
       array(1) { [0]=>
       array(4) { ["taxonomy"]=> string(8) "language" ["field"]=> string(16) "term_taxonomy_id" ["terms"]=> int(5) ["operator"]=> string(2) "IN" }
       }

    Weird. The updated plugin doesn’t have any function named “pll_woocommerce_get_cart_page_id”. Anyway, I think that you can disable the WooCommerce Polylang Integration plugin because the WooPoly one does all the things that the WooCommerce Polylang Integration plugin does plus more.

    Thread Starter bainiade

    (@bainiade)

    Leemon, I got rid of the first ” WC Polylang Integration” plugin and I don’t get the ” Fatal Error message and my products description are still in French. So I guess your plugin works, but the Cart, the Checkout page and their links are still in English. Where do I change the English Text to the French one?

    I went to to the String Translation Tap and I don’t see any fields. I aslo switched to :
    ” The language is set from the directory name in pretty permalinks “. But nothing seems to change, let me know!

    Thanks.

    Just in case, have you downloaded and installed the WooCommerce language pack for the French language?

    Thread Starter bainiade

    (@bainiade)

    At the risk of sounding stupid, no I didn’t. Wouldn’t erase the english version though?

Viewing 15 replies - 1 through 15 (of 34 total)
  • The topic ‘Translating WooCommerce " Cart ", " Checkout " and Category pages.’ is closed to new replies.