• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Ani's Webdev Blog

A learning diary of website development

  • Home
  • Demo
    • Ajax Contact Form
  • WordPress
  • Front-end
  • Backend

[WordPress] How to use Polylang to translate Woocommerce variable products

Modified on: September 18, 2020

Using Polylang to translate Woocommerce simple products is quite straightforward. But for variable products, it is a bit tricky.

In this article, you will see steps by steps how to use Polylang to translate Woocommerce variable products.

Table of contents

  1. Polylang and Woocommerce
    1. What are variable products?
      1. How to use Polylang to translate Woocommerce variable products
        1. What are global attributes?
          1. Translating Woocommerce variable products
          2. Troubleshooting

            Polylang and Woocommerce

            Polylang is a plugin to have your website in multilanguage as it lets users create translated versions of pages, posts, media, categories, tags, and also other custom post types and taxonomies. For SEO benefits, the Polylang free version also translate slugs.

            But, to have Polylang enabled for Woocommerce products, you will need an extra plugin: Polylang for Woocommerce. And, also, you need to have Polylang Pro to have this plugin work.

            It is quite straighforward how to translate simple products. However, for variable products, Polylang for Woocommerce plugin synchronizes all variations and attributes over different versions of languages so it needs more steps to make the translation happen.

            What are variable products?

            Sometimes a product has variations. For example if you are selling shirts, the variations might be sizes, colors, and gender. It lets user select exactly the style of product they wish to have, that you are able to provide.

            For example, Mr. A wants to buy a blue XL shirt, while Ms. B needs the same looking shirt in pink XS. It is defined as one product, but variations.

            How to use Polylang to translate Woocommerce variable products

            You would need to use global attributes to have translated versions of product variations.

            What are global attributes?

            As the name said, global attributes are attributes that used over different products.

            For example, if you want to use the same variation of color for both a shirt and a hoodie (meaning that in both products, users can choose color), it would save time to create global attributes and load it into both of these products. So you don’t need to manually create a variation of color each time you want to include this variation in one product.

            Translating Woocommerce variable products

            Use Case

            Let me explain the use case a bit that you can follow the below instructions.

            Here I have a product: Fixation adapter for silencer (sorry for this not-so-common product).

            I would like to have variations for this product like:

            • Ruger Mark II-III bajonet adapter
            • Browning Buck Mark bajonet adapter
            • Sig Sauer Mosquito .22 adapter

            And I would like to have these variations translated to Finnish, German and French.

            How to do it

            Step 1: Create a global attribute
            From WordPress Dashboard column: Products > Attributes.
            Create a global attribute in Woocommerce
            Create a global attribute in Woocommerce

            You can add a new attribute by filling in the Name field and click Add attribute.

            As you see from the right section of the page, I already created a global attribute name Valitse tuote (meaning Choose Product in English).

            Step 2. Add a new term in the global attribute

            Click to Valitse tuote (or any name you have) from the right part of the page to start adding terms. Or, click Configure terms.

            Adding a new term for a global attribute, woocommerce
            Adding a new term for a global attribute, woocommerce

            Start adding a new term in the original language, in my case is Finnish. You will then see it appears in the right section of the page.

            Step 3. Add a translated version for the term you’ve just added
            polylang add new translated item to woocommerce global attribute

            Click to the + sign next to a term you want to have translated version. Filling in the Name field and click Add new {attribute-name} button

            Warning

            You must click to the Plus (+) sign next to the term you want to translate, because this way the system will understand and link the term over different languages. If you just Add a new term from the left part of the page, it won’t create any links between different languages.

            To make sure that you are creating a translated version of a term, not just a new term which does not link anywhere, check the Translations part in the left side, it has to show early translated version of the same term.

            check the polylang translation in global attribute, woocommmerce
            This part has to show early translated version of the same term.

            For so many times I forgot to check this, resulting in many orphaned terms that do not link anywhere. So be carefully do this step!

            Advice

            If a term has translated versions, it will show the Pen sign.

            global attribute if a term has polylang translation
            If a term has translated versions, it will show the Pen sign.
            Step 4. Loading the global attribute in a variable product

            From a single product editor, in Product data tab:

            • Set the Product data to Variable product
            • Select Attributes tab
            • Choose the global attribute in the dropdown list. In my case is Valitse tuote →
            • Click Add
            woocommerce set global attributes on variable products
            Loading the global attribute in a variable product

            After the attribute has been loaded into the view, next step:

            • Tick on Used for variations
            • Select as many terms as you like from the Value(s) field by start typing in the term name
            • Click Save attributes
            woocommerce select global attribute terms for variable products
            Select global attribute terms for variable products

            Now that the terms have been added to this single product. Next:

            • Choose Variations tab
            • Select from the dropdown list Create variations from all attributes
            • Click Go
            • Wait that the variations are loaded into the view
            woocommerce create variations for variable products
            Create variations for variable products in Woocommerce
            woocommerce attributes terms load successfully into the view
            Attributes terms load successfully into the view

            Next, click to the number (e.g #2518 in this case) to open a dialog and start filling in information for that specific variation (for example price, weight, dimensions, and so on).

            woocommerce set price for single product variation
            Set specific information for a single product variation

            After you are happy with the information, click Save changes.

            Then, click Update from the product editor.

            update product in woocommerce
            Update the product
            Step 5. Translate the global attribute name

            So far we have translated the global attribute terms. How about the name? You can find the global attributes to translate from WP Dashboard column > Languages > String translations.

            polylang translate woocommerce global attribute
            Using Polylang String translations to translate Woocommerce global attribute
            Step 6. Review the changes

            View the product and switch to different languages to see if the translated terms have been understand correctly.

            using polylang to translate woocommerce variable products in English and German
            View Polylang translated version of variable products in English and German

            Troubleshooting

            As I follow the process, there are some notices I would like to share with you.

            The process to translate terms in global attributes brings headaches.

            Really, it creates me severe headache when translating a term in 4 languages. Starting with creating a new term for the original language, then click the + sign to add translated version x 3 times.

            And then at a time, the Cache suddenly starts to prove its value and the list does not show the term translation state correctly. If you don’t see the terms, you can try to purge the cache.

            If you add a term several times and still don’t see it displayed in the list, probably you are in the wrong languages. Because, if you switch language in any other page, all the system language will be changed following that.

            Make sure that you are in the correct language state in polylang
            Make sure that you are in the correct language state

            Final good habit

            Always check each product page under ALL different languages to see if the translation item has been loaded correctly.

            Filed Under: Wordpress, Wordpress Plugins Tagged With: polylang

            Recent posts

            [WordPress] Let’s Make Plugin E01: A Simple View Count Plugin

            [WordPress] Create custom post type programmatically

            [WordPress] Open Images in Posts into Lightboxes On Clicks (Without Plugins)

            Reader Interactions

            You are here: Home / Wordpress / [WordPress] How to use Polylang to translate Woocommerce variable products

            Leave a Reply Cancel reply

            Your email address will not be published. Required fields are marked *

            Primary Sidebar

            Hi! I am a Vietnamese coder living in Oulu, Finland. Currently I am working with PHP, MySQL, HTML, CSS, and JavaScript. This blog is my learning diary, in which I share knowledge from my own experience or research. Hopefully you can find something useful here and don’t hesitate to open a discussion or leave a feedback!

            FOLLOW MY BLOG

            Thank you for visiting this website! I hope you find something useful here :). Contact me by email: anh@anhkarppinen.com.