Note: This blog post was written in 2015, so there is no guarantee that the solution still works. However new comments keep coming in confirming that it still works (see comments section below) 🙂
If you are building a multilingual ecommerce WordPress website using the plugins WooCommerce and Polylang, you might run into a bug. Thus you can translate your products and product categories in your wp-admin, WooCommerce can not figure out to shift properly between your translations on the frontend. This happens because WooCommerce does not natively support Polylang’s translations. Learn here how to fix this bug.
While developing a multilingual ecommerce website with WordPress using WooCommerce and Polylang, I ran into this strange bug on the frontend. I had all my products, taxonomies and pages in WooCommerce translated with Polylang, and still it didn’t work.
The issues occurred were:
- shifting language on a product resulted in 404 error page
- “Proceed to checkout” button on Cart page did not work
- various broken links in WooCommerce
I deep-dived into the codebase of WooCommerce and found that WooCommerce does not natively support or understand how Polylang’s translations work.
In my debugging research, I did find a way to fix it. Here goes:
How to fix WooCommerce to work with Polylang translations:
Step 1: Open the file wc-page-functions.php
Navigate to this file “wp-content/plugins/woocommerce/includes/wc-page-functions.php” and open it in a text editor.
Step 2: Search and replace code
Find the function called “wc_get_page_id( $page )” and then this line:
$page = apply_filters( 'woocommerce_get_' . $page . '_page_id', get_option('woocommerce_' . $page . '_page_id' ) );
and replace it with:
$page = function_exists('pll_get_post') ? apply_filters( 'woocommerce_get_' . $page . '_page_id', pll_get_post ( get_option('woocommerce_' . $page . '_page_id' ) ) ) : apply_filters( 'woocommerce_get_' . $page . '_page_id', get_option('woocommerce_' . $page . '_page_id' ) );
Step 3: Done!
Fixed! Now WooCommerce understands your Polylang-translated pages 🙂
Curious about what the code fix does? In short it does:
- Checking that Polylang is installed and the function “pll_get_post” exists.
- If above line is true, WooCommerce must look for the translated page of whatever page WooCommerce is looking for
- … else just use the standard page.
Code fix doesn’t work? Correct your settings in WooCommerce and Polylang
If applying the code fix does not solve your issue, please go through this guide and make sure your settings are exactly the same as described here.
These settings are proven to make WooCommerce and WordPress understand the translation-links between WooCommerce pages, cart, checkout etc.
In this example I have two languages enabled: English as default/base language and Danish as second language.
- Translate the WooCommerce required pages
Login to your WordPress admin and go to “Pages”. Make sure you have created the three minimum required pages: Cart, Checkout and Terms – and you have them “translated” to the other language(s) as well.
- Correct your Checkout settings in WooCommerce
Go to WooCommerce > Settings > Checkout.
Make sure your pages are selected in the dropdowns in “Checkout Pages”.
- Correct your Languages settings in Polylang
Go to Settings > Languages (Polylang) > Settings.
Make sure your settings match the settings on this screenshot:
- Done! You’re good to go!
Disclaimer
The code fix in this blog post is not the best way to solve the issue. However it is currently the only way, as WooCommerce does not natively support Polylang’s translations on the frontend.
Replacing code in the plugin is a bad solution because our change can get removed/overridden when a new update of WooCommerce is installed.
Therefore: if you do use this fix, please be careful when updating WooCommerce in the future.
Which versions does it work with?
2015-06-26: Tested working with WooCommerce version 2.3.11 and Polylang version 1.7.6
2015-08-12: Tested working with WooCommerce version 2.4.3 and Polylang version 1.7.8
2015-09-01: Tested working with WooCommerce version 2.4.6 and Polylang version 1.7.9
2015-10-12: Tested working with WooCommerce version 2.4.7 and Polylang version 1.7.10
2015-12-01: Tested working with WooCommerce version 2.4.10 and Polylang version 1.7.12
I love your feedback!
I love to hear from you guys on how it works out for you. So please feel free to comment and share. I am happy to help as well 🙂
Thanks works well 🙂
Glad I could help, Sergio 🙂
thaaaaanks
You’re welcome!
Hello,
This works perfect!
Grtz,
Christophe
Hi Christophe,
Thank you for your feedback. Glad I could help 🙂
Best regards
Jesper
Hi Jesper
My problem is a Woocommercce + polylang integration. The “Proceed to Checkout” button in the cart page is linking to a blank page. i have used your code, but did not solve the problem. Could you help me please?
I working with WooCommerce version 2.3.13 and Polylang version 1.7.8
Hi Rorro
Are you sure that you have all the pages from the base language translated into all your other languages? In the WooCommerce settings you need to select the pages from the base language, and then the code fix will find your “translated” versions.
Please let me know how it works out for you. I will be glad to assist you.
Best regards
Hi Rorro
I have just updated the blog post with an extra chapter on how to set the correct settings in WooCommerce and Polylang. Please have a look at this and see if it can help you.
Best regards
Jesper
Hello Jesper,
thanks, but it is unfortunately not working on my page..
Regards,
Konstantin
There is still the problem “proceed to checkout” button on Cart page won’t work”
Hi Konstantin
Are you sure that you have all the pages from the base language translated into all your other languages? In the WooCommerce settings you need to select the pages from the base language, and then the code fix will find your “translated” versions.
Please let me know how it works out for you. I will be glad to assist you.
Best regards
Hi Jesper,
What do you mean by:
“In the WooCommerce settings you need to select the pages from the base language”
I can’t see any language options in WooCommerce. I have all my pages appropriately translated with Polylang, I just can’t get anything to show up for my cart in my second language…
Pretty much have the same problem as everyone else here.
Thanks so much for your help,
Julien
Hi Julien
I have just updated the blog post with an extra chapter on how to set the correct settings in WooCommerce and Polylang. Please have a look at this and see if it can help you.
Best regards
Jesper
I tried your code and it doesn’t work still. Pretty new to WordPress, is there some other setting I need to set in order to get the Cart and Check out pages show up in the french version of it?
Thanks
Juan
OMG, it was a cached issue I think. Works like a charm now..thanks so much for your help.
Hi Juan
I am happy to hear it worked for you when the cache was removed. Great! 🙂
Best regards
Hello Jesper,
how do you solve the problem with the payment methods settings in the checkout process? I can only choose between english or german version, but not both parallel.
Thank you and best regards
Brian
Hi Brian
I am not sure I understand your issue. Can you try to explain a bit more?
Please note, I have just updated the blog post with an extra chapter on how to set the correct settings in WooCommerce and Polylang. Please have a look at this and see if it can help you.
Best regards
Jesper
Worked like charm for me. Thanks! One thing – would you know how one could translate products? as it is right now, a translated product is treated as an independent product by woo commerce hence not working right.
Thank you for your feedback! Glad to hear it worked for you.
Yes, each translation of a product is as we speak treated as individual products – just with link to each other. Just like posts and pages. I have managed to live with it, but I hope some day they will improve this area 🙂
Having problems with checkout page… it only works if polylang is deactivated …. can’t get rid off spining circles.
wp vr 4.3
wooc 2.4.6
polylang 1.7.9 before update everything worked ok (as far as i know)
update:
if in setttings admin activates :
Setting>>Languages{polylang}>>Settings[tab]>>Hide URL language information for default language [check box] check for default language checkout page is normal
Hi Eugen. I can’t seem to reproduce this error.
My Polylang settings are:
– The language is set from the directory name in pretty permalinks = true
– Hide URL language information for default language = false
I hope you manage to solve it. Otherwise let me know, and I will be happy to assist you 🙂
it defenitly has a problem with extra data in url
so for me the sollution is to set in polylang settings that language is set from content… however other plugin will not work 🙂
Hi again Eugen
So you did manage to solve it, by setting the Polylang setting “The language is set from the directory name in pretty permalinks” to true?
Jesper
Hi Eugen
I have just updated the blog post with an extra chapter on how to set the correct settings in WooCommerce and Polylang. Please have a look at this and see if it can help you.
Best regards
Jesper
I still can’t get it to work. I had set the values you indicated in wc-page-functions.php, created the default pages in both languages, deleted the cache. And every time that I tried to access a product it redirects me to a 404 page. Any suggestions?
My Setup:
WP: 4.3, WooCommerce version 2.4.6 and Polylang version 1.7.9
PS: If I disable Polylang and I refresh the permalinks it works again.
Perfect! You are my hero, bro!
You too, my friend. Glad I could help 🙂
Best regards
Jesper
Thank you very much! Your excellent blog post solved my problem with Swedish-English!
Hi Kristian! Thank you for your feedback. I am very glad to hear it solved your problem! 🙂
Best regards Jesper
Hi Jesper,
First of all, let me tell you how amazed I am to have found your blog. I really didn’t think I would find any solution for this problem. Great stuff!
I tried your solution but I don’t seem to find any difference. I made sure all the settings were fine both in Woocommerce and Polylang, do you have an idea where to look? The plugin is fine let’s say 90% of the job but the 10% left make it horrible to navigate.
Hi Max
Wow, thank you very much for your kind words 🙂
Have you applied the “code fix” to the WooCommerce plugin file, as well as corrected the settings in the plugins via wp-admin?
Best regards
Jesper
Hi Jesper,
I never had any problem with pages translation. My only problem is that some buttons and text (such as “subtotal, view cart, etc.) don’t get translated. I did apply your code fix and check all settings were ok. But I don’t know what else to look for. The plugin I use is WooCommerce compliant, this means there’s a WooCommerce directory inside the theme. Do you think this has to do with the problem?
Best.
Hi Max
If it’s some text strings that are not being translated when you change language, it might have to do with the translations are actually missing/not available.
You can manage translations easily for plugins, themes and WordPress core with the plugin Loco Translate: https://wordpress.org/plugins/loco-translate/
Please have a look at it. It might be your solution 🙂 keep me posted.
Best regards
Jesper
Thanks Jesper, actually I was looking for this plugin! Well, I think my problem is somewhere else because on the cart page, I can’t manage to translate “Cart Subtotal”, “VAT” and “Order Total”. I even looked at the .po & .pot files I only found “VAT” but nothing changes when I translate it in French. But for example “Cart Totals” works fine when translated. I really don’t get it.
Hi Max
Your problem sounds strange, and I can not be 100 % certain that it’s an issue with the plugins anymore. If you want to, you are very welcome to drop me a private mail with more details (link to your website etc.), and then I will gladly have a look at it.
You can use the contact form on the Contact page.
Best regards
Jesper
Hey Jesper,
First of all thank you for putting your time and effort on finding a solution for this. I have been looking at a blank page for a long time scratching my head and then found this thread.
I have applied your code to the plugin however I am still seeing an empty page. Could you look into this.
Thanks
Hemal
PS:
WP V 4.3
WOO V 2.4.7
Poly V 1.7.10
Hi Hemal
Thank you, I appreciate you taking the time to read my post.
You say you have applied the code-fix. Have you checked your settings too, and made sure they are as I write in the post also? An empty page somewhere sounds like a translated version of that page is missing, or not configured/set by Polylang. Or maybe a cache issue – have you cleared your cache? Try using an incognito tab (Chrome) 🙂
Best regards
Jesper
Alternatively you can use this plugin: Hyyan WooCommerce Polylang Integration
Well, yes, that plugin really does a trick. However my experience is that the plugin does not solve the particular issue introduced by using the combination of WooCommerce and Polylang: e.g. switching language on the cart page. Only with the code fix I have provided in this post, it is 100 % resolved. Best regards Jesper Lund
Thank you very much for this workaround!
I’ve spent a couple of days trying to make various WooCommerce Polylang Integration plugins to work without success, before trying your method – just because you’ve said the method was ‘dirty’ (ie. might get overwritten by future WC updates). Now it works perfectly on my site, which features a webshop in English, German and Italian. (now I wish I could also implement different currencies and select the countries where a particular version can be sold…).
I just wanted to point out that you need to have other integration plugins disabled (I’ve first replaced the code, and it wouldn’t work – until I’ve disabled the WC-PL Integration plugin).
Additionally, is there some way to code this change so it ‘injects’, say from functions.php, into the WooCommerce file, so it remains stable with future WC updates?
Is the current best practice to repeat this code edit when the wc-page-functions.php updates?
Hi Neven
Thank you for your great feedback! I am very happy that my blog post helped you make your multilingual webshop work 🙂
Regarding other plugins disabled: Yes, that is my experience, too. Clean installation of WooCommerce and then just apply this ‘dirty’ code fix.
In manner of injecting the code fix into the WooCommerce plugin via e.g. functions.php is a desire I have too. If there was a quick and working method to do this already, I would have posted it immediately. However, the way the WooCommerce plugin is structured currently, we can not inject anything into that particular method. Not in a way I am aware of, I believe. If anyone read this and do not agree, please let me know, so we can help each other 🙂
Neven, if I come up with a more ‘pretty’ solution, and still as functional and out-of-the-box-working solution, I will let you know 🙂
Have a nice day.
Best regards
Jesper
Amazing material. Just what I ended up being exploring for!
Best regards,
It seems this has finally been fixed as of version 2.4.8; checking the code indicates a lot of deprecated content has finally been put to rest.
Can anyone else please corroborate?
Ouch… I’ve spoke too soon. The new setup just redirects back to original language, you still need the code edit. But at least it still works. 😉
Hi again Neven
Thank you for digging into it, in the search of a more ‘pretty’ solution.
From what I know, we still have to make my described code fix in the WooCommerce plugin code.
Best regards
Jesper
Hi Jesper,
many thank for you contribution and the effort you are putting into helping other. Your site really helps.
But there is still one issue I can’t get solved.
In the cart VAT etc. is translated just fine.
But on the product pages afte the price it still says inlc. VAT instead of inkl. Moms as I woul like ti to be in the swedish translation. Looked with Loco translate but can not find anymore missing translations.
Can you please advice?
Hi Christian. Thank you, I am glad I could help you. The code fix should in fact not address the issue you are describing. The only thing the code fix is doing is getting the right translated page when switching language. To fix your issue, you should continue looking into language files across the entire WooCommerce plugin. Somewhere, the text bit must be found, and then can be translated. Best regards Jesper
Hi Jesper.
I tried your fix code but I have a problem that I can’t fix.
I duplicated the single product (is not automatic… sigh) but if I buy 1 item in english, in italian the item is always there (I work with stock product).
How fix that?
Sorry if my english is not good, I hope you understand well.
Thanks.
I tried also “Hyyan WooCommerce Polylang Integration” but don’t work with Variation Product…
Hi Matteo. The problem you describe exists, even if my code fix is applied. The issue is that WooCommerce does not have support for multilingual products natively. The way a product is translated in WooCommerce is, in fact, that you duplicate the product to another language, and then link the two together – just as you have done, and just as it is with other content types, eg. posts and pages. The ‘in stock’ number will only be affected on the language the product is being sold in. Unfortunately. Best regards Jesper
Hi Jesper,
First of all; thank you. I was completely stuck with Polylang & Woocommerce and then you saved the day (sort-of)
I only have one small problem. At my webshop (batu.be/batu-development), when I add a product through the general shop page, this works. But at the single-product level, I receive the blank page.
Could you help me? Even if it would help only a little 😉
Thanks in advance
Small update; If i select the option:”sent to cart page when successfully added the product” it fails. If I unselect this, thus staying on the product page, all is fine 🙂
Hi Jochem! Thanks for your comment. I am very glad that I could sort-of save your day 😉 to me, your issue sounds like, you don’t have a “translated version” of your cart page. Make sure you have created a page (and have linked/translated versions of it in all of your languages) you name “Cart” (or whatever it is in your language) and then select this page as the Cart page in the WooCommerce settings. Also please make sure it is not a cache issue; use a different browser with all caches cleared.
Try it out, and let me know if it helped.
Best regards Jesper Lund
Hey Jesper,
I would much appreciate your help. I integrated WooCommerce with Polylang and that’s most because of your excellent work – thanks! But one thing I cannot set correctly. I have polish and english products on the page. My polish (default) version of the vebsite works good. After switching onto english version I get the product preview image in the shop, but not the product details. When I click the product I get 404. URL addresses are exactly the same. Do you have any idea what may be wrong?
Thanks in advance,
Sławek
Hi Slawek. Thanks for your feedback and kind words! From what you describe, I can not for sure say what the problem is. But it does sound like you have messed something up a bit, if the URLs of the products are the same. As a product in one language with a copy/translation in another language are not identical, likewise should the permalinks not be the same. It is Polylang’s responsibility to have your translated versions linked together, no matter how the URLs are formed and what the product titles are. Please make sure that your translated versions of both pages and products are linked together with Polylang. How to: When editing a page or product, check the box on the right and make sure the translated versions are selected in the input fields.
I hope this will help you.
Best regards Jesper Lund
Hi Jesper,
Thanks for the hint.
Regarding links, maybe I misleaded you… what I meant, URLs are the same for one language. For example:
I have product thumbnail in my homepage with destination to the correct (the same) URL set as product page.
For example, product page is:
http://kropki3.pl/en/sklep/violet-black-en/
and thumbnail destination URL is
http://kropki3.pl/en/sklep/violet-black-en/
Although the URL is correct, after clicking into the thumbnail I get 404.
Difference between both languages are made by “en” element in URL. For examlpe:
Link to the polish version (works):
http://kropki3.pl/sklep/violet-black/
Link to the english version (doesn’t work):
http://kropki3.pl/en/sklep/violet-black-en/
Thanks in advantage!
Sławek
Hi Slawek. Have you tried reconfigured your permalinks settings and Polylang languages settings by the instructions I have provided in the blog post? I think it might could solve your issue.
Best regards Jesper
Hi Jesper,
Yes, I tried configuration you posted and also tried different variations of it.
When I set settings exactly like you did:
– polish (default) version of the shop displays product pages as blog pages – not as woocommerce product pages
– in english version every thumbnail of the products which are on the homepage, link to homepage of the polish version. Exactly the same happens after clicking any product on the “shop” page
After selecting “Hide URL information to the default language” and leaving every else in the order you posted:
– polish (default) version of entire vebsite works
– english version of the shop stays the same – every product links to homepage of the polish (default) version of the site.
So now, I don’t get 404 error, but instead after clicking onto every english version product, I’m taken to polish version homepage…:/
Any ideas what may be wrong?
Regards,
Sławek
Hi Slawek. I wish I could help you more specifically, but to me it sounds more like a bug in WooCommerce, maybe an error in your theme or a configuration somewhere. I think you should try and ask the WooCommerce Support team, they are happy to help 🙂 Best regards Jesper
Hi Slawek & Jesper!
I am facing the same problem as Slawek did:
“I have product thumbnail in my homepage with destination to the correct (the same) URL set as product page.
For example, product page is:
http://kropki3.pl/en/sklep/violet-black-en/
and thumbnail destination URL is
http://kropki3.pl/en/sklep/violet-black-en/
Although the URL is correct, after clicking into the thumbnail I get 404.”
What is different here:
-I have not set a default language.
-I am not using Woocommerce as shop, but just to display the portfolio…
It would be great if you could share your experience!!!
Thank you so much for your help!!
Iga
Hi, I’ve followed your guide but for my site it doesn’t work… In this moment I’ve left all to original files.
Can you help me?
This is my official store in italian and my big problem is to have also the checkout and cart translated in english when someone tries to download something in the english section of the website.
http://store.delord.it , click on the english flag and try by yourself. Thank you so much
Hi Delord. Please make sure that your translated versions of both pages and products (if those are translated too) are linked together with Polylang. How to: When editing a page or product, check the box on the right and make sure the translated versions are selected in the input fields.
Next, make sure that in the WooCommerce settings, the pages in the base language are selected correctly.
When doing this, you need to have the code-fix described in this blog post applied. And please make sure that it is not a cache issue in your browser, when trying to access your cart or checkout page and things don’t seem to work 🙂
I hope this will help you.
Best regards Jesper Lund
Hi Jesper,
thank you so much! I’ve tried following your advice but it seems like the problem is that when I create the english version of the pages, polylang doesn’t connect both the pages… the language is correct but no translation associated with pages but the pages exists!
I think it’s a bug of Polylang…
Hi DeLord. From only reading your description, I can not determine whether it’s a bug in Polylang or a tiny mistake in the way you create your translations. However, I know it can be working, you can try reinstalling Polylang and re-setting up the configuration (follow the instructions in this blog post) and do the translations again. Please make sure that you don’t have any other plugins installed and activated that could interfere with Polylang’s behaviour. Hope this can help you.
Best regards Jesper
Hi Jesper,
Just wanted to say thank you very, very much for this post. I was getting crazy until I found you and changed the code!
Everything works fine.
Thanks!!!
Hi Laura. Thanks for your comment, I am so happy I could help you 🙂
Best regards Jesper Lund
Thank you so much!
Hi Pedja! Glad I could help 🙂
Best regards Jesper Lund
Hi Jesper again,
I found something that is not working and wanted to ask you if you could give me a solution.
It’s about the Wish list: after adding a product to the wishlist and clicking on the same icon to browse the wishlist, I get the 404 error and the url of that is [link removed]. I don’t know why there is this /TZJWV8NVWBUD/.
The second problem is that it seems that polylang plugin doesn’t recognize that the product is the same in different languages. Actually is I mark as favourite a product in a language, then I also can mark it in another language.
Well, the second problem is not a real problem, normally people just browse in one language… The first one is most importante. Is you could help me I really appreciate it a lot.
Thank you
Laura
Sorry, could you please delete the url that I’ve posted in my message? I just wanted to write a part of that, but finally didn’t correct it. Thank you 🙂
Hi again,
I’ve solved thet first problem!!
Thank you anyway 🙂
Hi Laura! I’m glad my blog post could help you solving your problems 🙂 regarding your second problem: the issue is that when translating a product in WooCommerce with Polylang, it is actually two separate products with its own identities. Polylang just creates a link between them. That’s why favoritising one product doesn’t automatically favourite the translation/other product as well, because it is not natively supported by WooCommerce.
The code fix I have provided is only for making WooCommerce understand browsing between linked products.
Best regards Jesper
HI Jesper,
Thank you again. Finally I found an answer in the support of Polylang plugin.
Now I have this new problem :(.
I installed a plugin that allow people to pay by credit card (with my bank), everything is fine until when you submit the order and get the Error 404. The url that appears is:
[mysite.com]/en/complete-your-order/[NUMBER of ORDER]/order-received/[number of order]?key=vc_order_[code].
The first NUMBER of ORDER shouldn’t appear…
The strange thing is that paying by Paypal everything works fine and after submitting the order I get the correct page of “Thank you for your order…” and the correct url with the Order number only once.
Do you have any ideas?
Thank you always 🙂
Hi Laura. I wish I could help you, but I’m no expert in every plugin out there. Please contact the author of the plugin instead 🙂 Best regards Jesper
Hi, firts sorry for my english. I have a proble on checkout page. In the default langeuage works great, but in the other language (in this case english) the Your Order area is blocked, i can select Shipping and pay mode.
Screenshot: https://www.dropbox.com/s/sgg4x6lpci74hm8/checkout-error.jpg?dl=0
Hi Alfonso. I am not sure if this issue is related to making Polylang work with WooCommerce. Looks more like a bug in WooCommerce. I think you should try contacting WooCommerce support team instead 🙂
Best regards Jesper
Hi!
Thank you so much for this valuable help!!! I wanted to ask before I do it: All of my permalinks are built from content, when I change that, I imagine that all my permalinks will change and all the links that are connected to my website from outside will we broken right?
Thank you so much for your kind help,
Juliana.
Hi Juliana. Glad I could help you! If you change your permalinks and have static links pointing to your “old” permalinks, then yes, they will be broken. In this case you can use the plugin Redirection for setting up redirects from the old permalinks to new permalinks. It works really well.
Best regards
Jesper
Great! Thanks! This fix solved several problems, including one that had appeared after installing the WooCommerce EU VAT Number plugin – leading to a zero total at checkout for all checkout pages but the one directly pointed to in the WooCommerce settings… it worked correctly before adding that plugin. But other problems were coming and going and they seem to have been fixed (at least after a quick test just now – hope that it will last). Jørgen.
Hi Jørgen. There is definitely a lot of edge cases around with WooCommerce, but I’m glad my fix seems to help you 🙂 Best regards Jesper
Hi,
Thank you very much for your post !
However i have an issue related to woocommerce / polylang and maybe you could help me :
My default language is French.
My second language is English
When i create a new product for products in French, woocommerce creates an url which is :
http://www.mysite.com/produit/the-name-of-the-product
which is fine.
However when i create a new product for products in English :
woocommerce creates an url which is :
http://www.mysite.com/en/produit/the-name-of-the-product
whereas default links to products displayed on the English shop page are
http://www.mysite/en/product/the-name-of-the-product
so when clicking on these products on the English shop page, i get a 404 for every product (which “real” url in woo commerce is http://www.mysite.com/produit/the-name-of-the-product
=> How can i do to set the product url for english products to
http://www.mysite/en/product/the-name-of-the-product and not http://www.mysite/en/produit/the-name-of-the-product
Thank you in advance for your help !
Hi Frank. I see your problem. It seems like WordPress/WooCommerce are having a hard time figuring out your permalinks. However, it also seems that you hide the language code for your default language, French. Try changing this configuration, so that all of your permalinks will be prefixed with the language code (mysite.com/xx/).
To do this please see step 3 in “Correct settings for WooCommerce and Polylang” in my blog post (www.jln.dk/wp-content/uploads/2015/06/settings3.png), and make sure your settings look exactly the same as on the screenshot. Afterwards, go to your WordPress Settings > Permalinks > Choose “Post name” option and hit save. This is resetting your permalinks configuration, helps avoiding conflicts.
Hope this helps you, Frank. Please let me know how it works out.
Best regards
Jesper Lund
Hi Jesper,
Thank you for your answer.
Currently the URL for my default language are like this : mysite.com
Does the fact of changing these URL to mysite.com/fr will not affect the internal links and links from external website to my website… ? In other words, will this create 404 errors for visitors from external links, based on URL without /fr in the link ?
thank you for your answer,
Frank
Hi Frank. Yes, changing the URL/permalink structure of your website will result in broken links if they are static or from external websites. However you can handle this by setting up redirects. Try out the free plugin “Redirection”. It solves it very well. Best regards Jesper
Thank you for the fix, and for spending the time verifying that it works with each version of WooCommerce. I understand the problem of multiply product translated version existing, just wondering how you solve the problem of the Shop page displaying only the translated version of each language? Or should this be a part of the fix and I didn’t do it correctly? Thanks in advance.
Hi Robert. Thanks for your comment. When you say “shop page”, which page are you then referring to? Not sure I understand completely.
Thanks for the reply. I meant the default WooCommerce shop page that lists all the products. I’d like to see only the English version of the products, or the French when applicable, but not both.
Hi Robert. That’s exactly the way it behaves, no worries about that. Have you tried it out? Best regards Jesper Lund
Sorry if I wasn’t clear. I have both versions of the product showing instead of just one, regardless of the language version of the Shop page. Is this normal?
Hi Robert. It doesn’t sound normal. Drop me an email by using the form on my Contact page, and I will gladly try and help you out. Best regards Jesper Lund
I realize this is old, but might be useful to have for others browsing this solution (Thanks!! Jesper).
In Polylang there is a setting for what to translate. If the box for Products is not checked, whatever Products exist will be shown for all languages. If it is checked, only the Products with a translation for ‘that’ language will be shown.
Ok Jesper, thank you anyway for all your help!
Regards
Hi Jesper,
Thanx for the great fix, It works like a charm. Only error I have left is a 404 error on the return page after payment, it doen’t include the /en/ or /nl/ in the adress.
Working with 1.7.12 polylang and the 2.1.0 woocommerce.
Or do I need to contact the paymentsuplier? For your info Mollie payments
Thanks in Advance
Hi Joost. Thanks for your comment! Glad to hear it worked for you 🙂
I think you should try asking your payment supplier for any fix to your bug. It sounds like the callback URL being sent is incorrect, but I don’t know for sure.
Best regards Jesper
Hi Jesper,
Thanks you for the post. It helps me. Really, thanks. I 3 hours searched in google to solved my problem with cart.
But now I still have a problem: descrip of payment method on english page in main language
http://joxi.ru/Q2KD8P8s94551A
Can you halp with this?
Hi Katia. No, unfortunately I can’t help you with that. But my guess is, that the language files containing the text strings for that page, is missing some translations.
Best regards
Jesper
Jesper, you saved my day!!!!!!!! Thank you soooo much!!!!!
Peng, I am so happy to hear that. Thanks for letting me know 🙂
Best regards Jesper
We still have the same problems as before.. when using “The language is set from the directory name in pretty permalinks” our menu does not work in both languages properly unless you click around, and when using “The language is set from content” the view cart button always appears in the same language. It is driving us crazy, as everything works if you click around.. which tells us that there is not something seriously wrong or missing, but we cannot expect our customer to do this.. we would be very glad if finally somebody finds a solution 🙂
Hi, what is your solution different from the existing Hyyan woo-poly-integration plugin? Does your solution handle Variable Products correctly?
Patrick, in the beginning of the blog post I point out which issues this fix solves. Best regards Jesper
Worked like charm , Thank you 🙂
Yay, glad to hear that, Alev! 🙂
Best regards Jesper
Thank you sooo much for saving me hours of frustration…
Just one more step you may want to include in your setup instructions…
I had the same problem as Frank 30th Nov with the product URL but easily fixed…
Settings – Permalinks – Product Permalinks change from Standard to Shop base.
Best Regards
Simon & Saloua
Maxi Pipa & Lord CoCo
WP V 4.4.2
WOO V 2.5.2
Poly V 1.8.1
Hi Simon! Glad I could help, and thanks for sharing that fix 🙂
Best regards Jesper
Excellent! Works great!
After updating woocommerce, i stuck..why this functions does not work! I replace it again and it works!
Great, glad to hear that, Daniel! Have a great Tuesday 🙂 Jesper
Hi everybody !
Thank you very much for the tips ! However I still have one problem. My checkout page is empty ! The cart page is ok, I have my product (It works for my two languages : French and English). I notice this problem for the two languages !
I’m alone with this issue ?
WOO 2.5.2
Poly 1.8.1
WP 4.4.2
Hi Thomas. I haven’t encountered that issue myself. Did you manage to solve it? Jesper
Hi,
I tried your fix but it did not work for me.
I have:
Wordpress 4.4.2
Woocommerce 2.5.2
Polylang 1.8.1
All woocommerce pages (my-account, terms, cart) return a 500 message.
As soon as I de-activate polylang everything works fine. I am developing an eshop which I need to operate with at least 3 languages, Greek, English and German (and possibly more in the future).
Any help would be greatly appreciated.
Hi,
I have :
Wordpress 4.4.2
Woocommerce 2.5.2
Polylang 1.8.1
When I click on any product 404 error pop-up. This issue is valid since I updated the woocommerce and wordpress. I don’t know which update cause the problem.
Please feel free any idea to solve the issue .
Thanks a lot!!!!!! just im searching. it rules.
Glad to hear that, Fernando 🙂
Hello,
thank you for your efforts to solve this problem we all have with Woocommerce and Polylang!
However, I have a new problem that I haven’t seen a solution here (nor that anyone has similar problems):
When I update the wc-page-functions.php, the languages seem to work great, except:
1. Webshop won’t translate to Webshop in another language. It just shows an empty page
2. After a few minutes, my wp-admin pages go blank, and I cannot login into Dashboard – also showing only a blank page
Can you help with these issues?
I am using:
Polylang 18.1.1
Woocommerce 2.5.2
Wordpress 4.4.2
Thank you!
I have tried everything in this post, I am not able to see my products. Always 404.
Actually “Oops! That page can’t be found.” is what I’m getting.
Hi
I can not set the page of my site multilingua.Products are placed in the shop page of the main language, and is generated fatal error
Catchable fatal error: Object of class WP_Error could not be converted to string in /web/htdocs/www.xxxxxxxxxxx.it/home/wp-content/themes/xxxxxxxx/inc/hook/core.php on line 459
Can you help me?
Seems like there is something wrong in one of your theme files. Not related to WooCommerce or Polylang 🙂
Tag Jesper,
thanks a lot.
Bugs are very frustrating; it must have cost you days of debugging. You saved me a lot of time; it still works perfect with me. And all those replies takes your time as well 🙂
But there will be a time that it will be fixed in one or other release (I assume).
I use:
WordPress 4.4.2
WooCommerce 2.5.3
WooCommerce Polylang Integration 0.2
PolyLang 1.8.4
Glad to hear it helped you, Arthur. Hopefully one day WooCommerce and Polylang will work together out-of-the-box 🙂 Jesper
Hi! your change “was” perfect! everything was fine, but with the last polylang update it doesnt work anymore….
I replace your change and put it as it was before, and it seems that the stores works well but not for checkout nor cart.
And in my case, the main store now has all the languages product include… so i have one in spanish, one in english, and one in french… in the same page…
:(!!!!!!
Hope you help us again.
Hi,
I try it but i have this error
Warning: preg_match() [function.preg-match]: Unknown modifier ‘0’ in /home/webtoapp/public_html/wp-includes/class-wp.php on line 207
Warning: preg_match() [function.preg-match]: Unknown modifier ‘0’ in /home/webtoapp/public_html/wp-includes/class-wp.php on line 208
Thanks again (I have written before) for this very useful fix. I have an additional problem – maybe you know the answer to that too?
Using WooCommerce with the Storefront theme and two languages set up through Loco, the cart info in the menu line keeps showing e.g. “2 items” in English, even though I have translated that text using Loco. In fact, the translated text displays briefly on page load, only to be immediately overwritten by the English text. How can I fix that?
Thanks – It worked like a charm!!!! Have a shop with that exact issue. My search is over! 🙂
Happy I could help you, David! 🙂 Jesper
Hi,
I use:
WordPress 4.4.2
WooCommerce 2.5.4
WooCommerce Polylang Integration 0.2
PolyLang 1.8.4
Page not found when iser language second.
Hey there,
Have you managed to translate attribute labels using polylang and woocommerce?
In my case, on both versions of the site, the attributes labels are being displayed in the main language only, they don’t work for the 2nd language.
Had the same issue. One year later. Have you found a solution for this?
Had the same issue today, found your post. The problem is, I (of course) hate modifying plugin’s code – the change will be vanished on a next update. And it will definitely happen on client’s website – the client will not remember that the WooCommerce code was modified.
However, your code actually gave me a hint. There’s a filter there. It’s dynamic (uses $page variable) so it’s a bit tricky to work with it. But after studying the WooCommerce code, I’ve found a solution. Add this to your functions.php and you’re done:
/**
* Make WooCommerce take into account translated pages.
*/
function pss_translate_woo_pages( $page ) {
return pll_get_post( $page );
}
add_filter( ‘woocommerce_get_myaccount_page_id’, ‘pss_translate_woo_pages’, 10, 1 );
add_filter( ‘woocommerce_get_edit_address_page_id’, ‘pss_translate_woo_pages’, 10, 1 );
add_filter( ‘woocommerce_get_shop_page_id’, ‘pss_translate_woo_pages’, 10, 1 );
add_filter( ‘woocommerce_get_cart_page_id’, ‘pss_translate_woo_pages’, 10, 1 );
add_filter( ‘woocommerce_get_checkout_page_id’, ‘pss_translate_woo_pages’, 10, 1 );
add_filter( ‘woocommerce_get_pay_page_id’, ‘pss_translate_woo_pages’, 10, 1 );
add_filter( ‘woocommerce_get_view_order_page_id’, ‘pss_translate_woo_pages’, 10, 1 );
add_filter( ‘woocommerce_get_terms_page_id’, ‘pss_translate_woo_pages’, 10, 1 );
Hi Ihor,
thanks for the code, unfortunately id did not work for me…and now the homepage does not get loaded…
You might have done something wrong. Try resetting and do it all over again 🙂
Hi Ihor. That’s actually a good catch and nice implementation. Does it work for you? 🙂 Jesper
Hi Jesper.
Thanks for your help.
It seems your code has solved my problem.
I’m making a Greek – English eshop with woocommerce 2.5.5 and Polylang 1.8.5.
I run into the same problems. My English Checkout and Shop pages were empty, but other like Cart and Home pages were ok. All the Greek pages were fine.
I followed your instructions and now everything works.
I went in WooCommerce > Settings > Checkout.
There I first changed the language to English, then selected my English pages in the dropdowns in “Checkout Pages”.
Strange, but if I switch back to Greek, the corresponding dropdowns in “Checkout Pages”, contain no page names.
Could you please elaborate on this?
Many thanks for your help
Costas Valanos
Thank you very much Jesper, it worked for me perfectly!! You have saved me a lot of time….
Glad to hear that, Hedvika 🙂 have a nice day!
Hi, I was wondering if this would anyhow fix the issue I am experiencing.
As an example, I have a product in the default language, I create the translation and all is fine from that perspective, except – and this is a huge issue – the inventory is not shared by the two translations.
The system treats the translated products as separate products. You can easily imagine what this means from a management perspective when you have more languages and thousands of products.
Do you think your fix would workaround this particular issue? Or do you know anything about this?
Hi Friggha. I totally get your point and issue. It’s a bit tricky in WooCommerce. Try contacting the WooCommerce support desk. They might have a solution for it 🙂
Thanks a lot for the code, it works perfect! Now the items are shown in shop of the 2nd language.
Sounds great! Thank you for your feedback 🙂
Worked great! Thank you
Happy to hear that. Thanks!
Thank you Jasper for the tutorial!! 🙂 i have tried all the above but i am facing problems. I have English and Greek and when i try to appear the products when i have site_url/products (page that i selected) it displays them fine but when i have site_url/en/products (that is what i want) it doesn’t appear the products. I now that is problem with the lang. Can you please help me?
Hi Alex. Try contacting WooCommerce support desk regarding your issue. They might have a solution 🙂
these options doesn’t work
Sure you did follow all the steps for setting it up? 🙂
You rock! English/Chinese pair. Products were being handled just fine by Polylang, but the Shop/Cart/Checkout wasn’t. Added your code and voila! Brilliant!
Question…
I have /en/shop (English). It correctly points to [woocommerce-shop].
If I hit the language switcher, it correctly switches to /zh/shop and displays the page in Chinese with my Chinese products [woocommerce-shop].
But… the name of the page should be /zh/shangdian.
If I point the Chinese menu to the /zh/shangdian, I get the problem described below for the breadcrumb —
I switch to Chinese, select an item in Chinese, and use the breadcrumb to return to the shop. The breadcrumb “correctly” points to /zh/shangdian (the Polylang paired page).
But then, when I use the language switcher, it tries to switch me to /en/shangdian (not /en/shop). And since it can’t find that page name, the language stays the same.
Any suggestions?
Hi Terri,
It seems you may have internal translation missing for correct permalink maping.
May be you can install the “check theme” plugin which will give you the list of words which are not been translated yet, then you know where to complete your .po & .mo files.
Hope this will help
Brgds,
Dan
PS : i forgot to ask if you already checked the page translation you need for your default “shop” base, go to :
wp-admin/admin.php?page=wc-status
so, click on the shop page which is setup by default, it will probably be the English version in your site, and check if there is a Chinese translation for it : if not, just add one.
Not much help, Dan. I had checked all the various things you pointed (and several others) before I posted the question. And no, there is no “internal translation” missing. It’s a code issue, not a text-typing issue.
If you have something specific you are willing to share, that would be super. Pointing here and there for me to “go chase” isn’t polite.
Hi again Terri,
May be this is related to your problem ?
http://stackoverflow.com/questions/17530026/woocommerce-breadcrumb-missing-shop-link
Brgds,
Dan
https://docs.woocommerce.com/document/customise-the-woocommerce-breadcrumb/
Dear Jergen,
Many thanks for this great job !
It works with :
Version WP : 4.5.3
Version WC : 2.6.4
Polylang : 2.0.2
Glad to hear that, Dan 🙂
Hello.. are these problems avoid with the paid – Polylang for Woocommerce of Polylang Pro ?
Thanks
I’m not sure, but I don’t think so. The code should be almost the same for paid and unpaid.
Hi Jesper,
I am very interested in this fix, as I have been using the plugin polylang for wc, but I got a conflict with another plugin ( genesis connect for wc )
2 questions:
— does it work with the latest version of wc: Version 2.6.4 and polylang : Version 2.0.4 ?
— when wc will publish a new version, your fix will be overwritten, how can apply it without needing to apply your fix each time wc upgrade to a new version?
Thanks a lot
Vincent
Hi Vincent
Thanks for your comment. Please note that my blog post is no longer up-to-date so the fix might not work as expected anymore. Sorry about that 🙂
Best regards
Jesper
Hi Jesper,
Thanks. This was an amazing way out and definitely a huge relief for me after splitting my hair out for long. Appreciation, admiration and thank you for keeping it in public and also answering so diligently to people about this.
Your solution worked on my website ( zumpak.com), though there is a very small error I noticed. So woocommerce is able to pick up translated texts for the pages(cart, checkout) and modify the intended url’s accordingly – but for the cart page for the non-default language unless a product is added to the cart. For eg- my website is in French and English(and I have set French as the default language and enabled browser detection for the website text)- and when I move from French to English, the cart is still pointed to the French web link(though the alt text gets translated) and acquires the English link only once when a product is added to it. I hope I could make you understand the issue.
Can I request you if you could tell me if I am missing anything here? Or is there a work out to the problem?
I again thank you for the work out to this problem. And beers on me if you come to Paris:)
Hi Saurabh
Thanks for your comment. Please note that my blog post is no longer up-to-date so the fix might not work as expected anymore. Sorry about that 🙂
Best regards
Jesper
Hi Jasper,
Thank you soooooo much! You are my hero 😀
Regards
Anna
Hi Anna
Thanks a lot – I’m glad to hear that 😉
Best regards
Jesper
Hi
First thank you for your help, that’s work.
Just one question : how do you fix the “myaccount” with the logout page ? I mean you have to choose to display which page to show and this page is either one language or another language.
For exemple, I choose to display the “english my account” and I am on the french website. When I will click on the “mon compte” page, I will be on an english dashboard.
Can you help me please ?
Thank you
Hi Jay
Thanks for your comment. Please note that my blog post is no longer up-to-date so the fix might not work as expected anymore. Sorry about that 🙂
Best regards
Jesper
Awsome!! Thank you for the great job!!!
It works for the shop page very well.
One question:
Is there any similar code or solution for product category page?
I fixed the blank page problem with my shop page.
In shop page i display the product categories but when I click on one of the categories I see blank page again.
Hi Ellh
Thanks for your comment. Please note that my blog post is no longer up-to-date so the fix might not work as expected anymore. Sorry about that 🙂
Best regards
Jesper
Hi Jesper, Thanks for posting this. Unfortunetally this did not work for me, for bizar reasons:
1. There is no “wp-content/plugins/woocommerce/includes/wc-page-functions.php” to be found in Includes… Strange but true. I searched in a few other files, but could not find.
2. I work with Polylang 2.0.12. But what is stranger: some of the options you check, aren’t in my WP version (4.7) For instance, there is no ‘The language is set from the directory name in pretty permalinks’.
To be honest I’m not entirely sure the problem lies with Woocommerce/ Polylang, because the PayPay system I integrated works just fine! (‘Proceed to PayPal’) Whereas integration of Mollie leaves this button blank. Mollie denies it’s an error on their side…
I was wondering if you have any suggestions for me?
The website I’m speaking of is https://www.timhupkes.com/shop
Particurely this page makes things interesting:
https://www.timhupkes.com/shop/?page_id=9&lang=en
The first ‘PayPal’ is the non-Mollie integration.
Happy Newyear (I was told I can still say that up to today :-))
Tim Hupkes
Hi Tim
Thanks for your comment. Please note that my blog post is no longer up-to-date so the fix might not work anymore (as you experience).
Best regards
Jesper
Big Thanks you for Tips!
I have a different question, but I hope you can help me (since you obviously know your way around WooCommerce and Polylang integration). In the past, everything was working normally, and now it’s not. (not sure from which update, tbh)
It may be the new changes, but for me your workaround still works, and the webshop is operable. The webshop does work (allows people to order and buy the products), however. No, I’ve got a different problem.
My WooCommerce (WC) shop is translated into English (default site language), German and Italian. I have several products, which have their own translated product pages.
Now, when I visit the German or Italian shop page, it correctly displays the products, with correct languages. Everything is working properly. But, on the default/english shop page, it displays 3 copies of each product – and they link to their German and Italian versions.
I am not using WC categories, tags or attributes. I have set the product language on the appropriate product page (and properly created translations from this page). The Custom post types and taxonomies setting in Polylang are all activated, and I’m using WC Product Permalink set to Shop Base.
How can I fix it so that the default shop page only shows products in the default language?
Please see the problem here:
http://mykosan.com/shop
And compare with the correctly working German and Italian versions at:
http://mykosan.com/de/shop
http://mykosan.com/it/shop
I’d really appreciate it if you could look into it. Thank you!
Plugin versions: WooCommerce 2.6.14, Polylang 2.1
Thank you very much! It worked for me!
You’re welcome!
Thanks. It appears that worked for me too. I’m using wordpress version 4.7.3, woocommerce Version 2.6.14 and WooCommerce Polylang Integration version 0.2 by Darko
Worked like a charm!!! Thank you I was struggling all day trying to figure this out now I have my website in both english and spanish up and running!! Thank you
Glad to hear you solved it. Thanks for commenting, Liliana.
Still working 2017-04-07! Thanks!
WordPress 4.7.3, Polylang 2.1.2 and WooCommerce 3.0.1
Note that you have to apply the fix then create the translated page.
Hi,
This is not the only way to solve the issue, the apply_filters line means that you can hook these filters.
The Pages.php in the Hyyan WooCommerce Polylang Integration shows a way to this.
Jon is right – apply_filters() means that you do not need to have to edit the core WooCommerce files.
Here is some code that should be able to do it using add_filter(). I haven’t tested the code but I conditionally used the pll_get_post() function in single-product/up-sells.php and cart/cross-sells.php template files a few minutes ago.
https://gist.github.com/damiencarbery/a9c4299613f09761b3d3fcfc3c6f0177
Dear Jesper,
I appreciate your work. However i have a problem regarding Polylang Language switcher with WooCommerce. If I am on a Product Page (with add to cart, description, etc..) The Language switcher works as expected. But if I am on the WooCommerce Shop site (Where all products are listed) the language switcher redirects me to a specific product every time instead of showing the shop site in the 2nd language..
Is there a way to fix this issue with Polylang? Or will I have to accept this?
Greetings from Germany,
Timo
Thank You With ALL MY HEART.
Woocommerce v 3.1.2 + Hyyan WooCommerce Polylang Integration v1.0.3 + Polylang v 2.2.1
It works
You’re welcome! I’m glad I could help.
May i ask why my top header cart link is not change link
always [mywebname/cart]?
how can solve it
Hello Jesper,
Thank you very much. Your language setting instructions helped me solve the ‘Your Order’ section auto translation problem we had on the checkout page. That part was automatically changing to the default language from the added language on our website.
Best Regards,
Cuneyt
Why don’t we just automate the replacement? If you are on Linux you could just paste this command into your terminal to do apply the required modification to “wc-page-functions.php”:
sed -i -e ‘s/\$page = apply_filters( ‘\”woocommerce_get_’\” \. \$page \. ‘\”_page_id’\”, get_option(‘\”woocommerce_’\” \. \$page \. ‘\”_page_id’\” ) );/$page = function_exists(‘pll_get_post’) ? apply_filters( ‘woocommerce_get_’ . $page . ‘_page_id’, pll_get_post ( get_option(‘woocommerce_’ . $page . ‘_page_id’ ) ) ) : apply_filters( ‘woocommerce_get_’ . $page . ‘_page_id’, get_option(‘woocommerce_’ . $page . ‘_page_id’ ) );/g’ ‘wp-content/plugins/woocommerce/includes/wc-page-functions.php’
With PHP the regex replace would probably be even easier.
Maybe someone could write a simple plugin that automatically does this whenever an update is installed, maybe jsut by checking if “wc-page-functions.php” changed every few minutes.
Hi Jesper!
The code worked for me for the main card page, but when it goes to the last page of the card where it appears the resume of the booking and the pay with card button it changes again. How can I fix it?
Thanks a lot!
hi Jesper Lund
I got a woocommerce error when working with polylang, although I updated the code as you posted it.
When updating your code, woocommerce does not work as it used to,
I put my product in the admin but when outside the page it is not displayed and the product category is not listed.
Can you help me with this error?
I am using version 3.4.4 of the woocommerce, using the flatsome version 3.5.3
I’m sorry but I do not maintain this blog post anymore, so I can’t help you with your issue. I hope you will find a solution!
hı . ı tried all your ways but it doesnt work.
when ı want to see my products page it shows a white blank screen and there is nothing in that page. Also when ı want to search some product at searchıng area it doesnt show the product that ı search. how can ı fix that problem?
Thanks. ı waiting your reply.
Best. Ertan K. from turkey
I’m sorry, Ertan. I do not maintain this blog post anymore, so I can’t help you with your issue. I hope you will find a solution!
YOU SAVED A LOT OF GREAT WORK FOR ME JESPER….thnx a LOT!!! GREAT and simple solution to solve the mini-cart popup text translation problems…I just followed 4 step solution as shown in your screenshot.
GREAT. THNX
You’re welcome, Cenk! Glad I could help you out.
Very Thank you for this post!
It’s very helpful!!!
Best wishes!
Thanks, Shohijahon. You’re welcome!
Hey!
It’s 2020 and this method STILL works!
Thank you very much!
woocommerce version: 4.5.1
polylang version: 2.8.2
Thank you from hungary!
Awesome, Misi! Didn’t know it still works. Thank you for commenting.
Nov 2020, still working !
Thanks a lot for this short and very usefull trick.
Do you know any way to add this in the function.php of my theme ?
The aim is to be able to update woocommerce maintaining this trick without having to touch the code again.
Thanks, Pierre! Glad to hear it works for you.
Unfortunately I don’t know if the code can be added through functions.php. But please keep me posted if you find a way to do it. Thanks!
Hi Jesper,
Thanks for answering.
I lost a lot of time looking to fix a bug I had with the shop page :
The site is in spanish (primary) and english, so the shop pages should be :
– mysite.com/tienda for spanish
– mysite.com/en/shop for english
The problem was that in the menu, and another button where I call the wc_get_page_permalink( ‘shop’ ), it works in one language but not the other.
The weirdest part is that if I actualize the spanish shop page last, then those links works :
– mysite.com/tienda for spanish
– mysite.com/en/tienda for english
but the wc_get_page_permalink( ‘shop’ ) for english send me to mysite.com/en/shop and show no product at all, and error in attributes filters
If I actualize the english shop page last, then those links works :
– mysite.com/shop for spanish
– mysite.com/en/shop for english
but the wc_get_page_permalink( ‘shop’ ) for spanish send me to mysite.com/tienda and show no product at all, and error in attributes filters
In both cases, the pll_switcher was working fine !
I couldn’t fix this bug, but found a solution (after two intenses days…) with the plugin Permalink Manager Lite and put the same slug in both shop pages (“shop” or “tienda”, both works).
Hope this trick can help other people.
To put everything in function.php, I tried the solution of Ihor (April 5, 2016) but doesn’t work.
I’ll follow any future solution because it’s a bit of a pain for every WooCommerce update.
Thanks again, best
YOU ARE FUCKING GOD!!!!!!!!!!!
Thank God! You the best!
still works 07/2023
It works for me at August os 2023 with WC 7.9.0 and PL 3.4.4
I create a plugin with the code of Ihor (https://blog.jln.dk/how-to-make-woocommerce-work-with-polylang-wordpress/#comment-125), With that way not lost the code with an update
Still works! Thx!
It works for my website at teoremenerji.com.tr in 2023!
Thank you so much
Great tuto!
Does it still work with WordPress 6.4.1, WooCommerce 8.3.1 and Polylang 3.5.2 ?
thank you.
This works perfectly in 2024!
Thanks!
Any way to get this to work as a code snippet without having to change the original woocommerce files (so it’s immune to plugin updates)?