Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
The client was experiencing two issues on the WooCommerce checkout page with WPML:
1) The product title on the order-pay endpoint page was not translating to the current page language but remained in the language the order was made in.
2) On the order-received page, the permalink slug for certain variable products with multiple attributes was in the wrong language.

Solution:
We recommended the following steps:
1) Go to WooCommerce > WooCommerce Multilingual > Status and complete any missing steps.
2) Navigate to WooCommerce > WooCommerce Multilingual > Store URLs and ensure that:
- Slugs are unique and not repeated across translations.
- Translations do not have the same slug as the original language.
If these steps are completed and the issue persists, we provided a code snippet to temporarily change the order language to English, retrieve the product information, and then revert the language back to the original. The client should add this snippet to their functions.php file. (fond here: https://wpml.org/forums/topic/woocommerce-product-title-etc-on-pay-order-checkout-page-in-wrong-language/page/2/#post-10513689 )

Please note that this solution might be outdated or not applicable to your case. If the issue persists, we highly recommend checking related known issues, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If necessary, please open a new support ticket with us."}

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 24 replies, has 2 voices.

Last updated by Alejandro 2 years, 12 months ago.

Assisted by: Alejandro.

Author Posts
January 25, 2022 at 1:49 am #10422851

ingoZ

Could you please look into this? Or at least make a duplicate of the site again so I do not need keep this exact staging environment online?

January 28, 2022 at 7:18 pm #10458793

ingoZ

Hello? Please take a look, I am still waiting and I need you to duplicate the staging environment so I can use this page for other purposes again!

January 29, 2022 at 9:09 am #10461299

Alejandro
Supporter

Languages: English (English ) Spanish (Español ) Italian (Italiano )

Timezone: Europe/Rome (GMT+01:00)

First of all, sorry for the huge delay, i had a few issues backing up the site this time.

I ran many tests and the problem + the solution were already discussed here but we needed to take a few extra measures to UPDATE the permalinks.

What i did can be seen here: hidden link

as you can see , you need to:

- Make sure you translate the endpoints from WooCommerce > WooCommerce Multilingual > Store URLs
- Make sure the slugs for all the pages under WooCommerce > WooCommerce Multilingual > Store URLs are ALL different, in your case "shop" was the same for English and German.

- you don't have the Italian language correctly setup so go to WooCommerce > WooCommerce Multilingual > Status and do what is shown on that page (Create the pages for Italian) and then run the 2 steps i just mentioned above.

- Last but not least, update everything about the products, on the database by going to WooCommerce > WooCommerce Multilingual > Settings > Troubleshooting (Select a few options at a time and run every single one available).

That should be all, i tested it:
- hidden link

- hidden link

and i see they are working correctly now.

January 29, 2022 at 5:15 pm #10462743

ingoZ

I see thats some progress. I just retested the steps you did and apperently the main thing that fixed the permalinks is just running the WPML multilingual troubleshooting (Store URLs etc. may be necessary for other things but seems unrelated to this).

However, it did not fix all issues unfortunately:
1) The troubleshooting somehow even resulted in another major issue, the product variation on the order-received and order-pay pages of any language now do show the main parent product thumbnail instead of the product variation (child product) thumbnail. If i revert to a backup of the site before the troubleshooting the correct variation image is shown.
I have added the thumbnail to the template in twentytwentyone/woocommerce/order-details-item.php so you can observe the issue on the order-received page:
hidden link
2) On the German order-pay page
hidden link
the product title still is in English instead of in German.
3) On all the English checkout pages the variation attribute pairs below the product title are in German (which was the language the order was made in originally). Should they not also be in the language of the checkout page (farbe: Weiß -> color: White)?

January 31, 2022 at 8:13 am #10467403

Alejandro
Supporter

Languages: English (English ) Spanish (Español ) Italian (Italiano )

Timezone: Europe/Rome (GMT+01:00)

The reason why the attributes are not translated is because they are all local attributes. if you want to see them translated please create the attributes as global attributes (products > Attributes) and then assign them to the translations.

that will probably fix the images issue, because i can see that you actually have different variations between the languages.

-------------------------

I also see that you seem to create the translations manually and if that's the case please make sure you have the translation editor deactivated on such products/pages (turn off the switch found under the "languages" section of the edited page.

Try that and let me know how it goes.

January 31, 2022 at 12:00 pm #10469737

ingoZ

1) As mentioned the variation image was shown correctly before the troubleshooting process, only not after it switched to the parent image. Why is that?

2) How about this issue I mentioned with the English product title on the German order-pay page only (on the order-confirmed page it's correct)?

3) The attributes are always unique to each product so I do not want to create global attributes for that. So with local attributes the WPML Plugin can not automaticly show the variation attributes of the translation? Shouldn't that be possible if the individual variations are linked with their variation translations too?

January 31, 2022 at 3:11 pm #10471993

Alejandro
Supporter

Languages: English (English ) Spanish (Español ) Italian (Italiano )

Timezone: Europe/Rome (GMT+01:00)

It should, even with local attributes, so please allow me to test a few things with our latest version (which was released just a few days ago) with our developers to see if i manage to recreate the problem because i tried earlier and the problem was not there, which makes me believe there's something going on with the site.

I'll come back with the results. in the meantime can you please let me know if at any point in time the default language of the site or of these products was ever modified?

January 31, 2022 at 9:36 pm #10474593

ingoZ

I do not think so. The products are all uploaded via the WP ALL Import plugin both in English and in German, maybe there is some relation to that. Pleaselet me know as soon as you found something out on all that three points.

Should I keep the current version of the site online, or better the one prior to running the troubleshooting because in this previous version the variation image at least was displayed correctly?

February 2, 2022 at 10:04 am #10488341

Alejandro
Supporter

Languages: English (English ) Spanish (Español ) Italian (Italiano )

Timezone: Europe/Rome (GMT+01:00)

I ran different tests and noticed something interesting:

- In the order-pay endpoint the content will always show the content in one language because the admin page of the order where you get the link to pay from, will never contain a language.

However and interestingly the links will actually be correct, but the information will always be the same. On my test it was always the default language of the site's text, on yours instead it was always german, which was actually the language the product was bought on (i'm not sure if the product's original language was ever "german" or if your site's default language was german at one point)

This is something that i'll split into a different ticket and send for review to our developers, to see if it's an expected behaviour of our code or not.

----------------------------------------

The "thank you page" instead was correct, it showed everything correctly, even the attributes translation in the correct language BUT i did notice that "old" orders BEFORE the endpoint translation would not work sometimes because the database was missing the unique identifier for this new endpoint (they didn't match. i'm talking about "key=wc_order_XXXXX" in the URL ).

This is expected since the thank you page should be seen only once and if the endpoint were translated, you'd see the correct identifier so the problem would never arise, in theory.

----------------------------------------------
About the thumbnails, that doesn't seem to be coming from the theme (i tested storefront and twentytwentyone) since i could only see the thumbnails on the cart, never after having bought the product or on the order-pay endpoint. could it be you added the thumbnail there?

you can check what i did here: hidden link

February 5, 2022 at 8:57 am #10513689

Alejandro
Supporter

Languages: English (English ) Spanish (Español ) Italian (Italiano )

Timezone: Europe/Rome (GMT+01:00)

Our dev told me that since the order doesn't allow us to have any language, the URL will change but not the product information, although its link will be localized because of the URL.

you can try the following snippet on your WP-FUNCTIONS.PHP to see if it could help with that:

// Temporarily change the Order-Language to 'en'
$current_order_wpml_language = get_post_meta($order->get_id(), 'wpml_language', true);
update_post_meta($order->get_id(), 'wpml_language', 'en');
 
/**
 * Get File Downloads from Order
 * - This is a Copy from $order->get_downloadable_items()
 */
foreach ($order->get_items() as $item) {
    if (!is_object($item)) {
        continue;
    }
 
    // Check item refunds.
    $refunded_qty = abs($order->get_qty_refunded_for_item($item->get_id()));
    if ($refunded_qty && $item->get_quantity() === $refunded_qty) {
        continue;
    }
 
    if ($item->is_type('line_item')) {
        $item_downloads = $item->get_item_downloads();
        $product = $item->get_product();
        if ($product && $item_downloads) {
            foreach ($item_downloads as $file) {
                $downloads[] = array(
                    'download_url' => $file['download_url'],
                    'download_id' => $file['id'],
                    'product_id' => $product->get_id(),
                    'product_name' => $product->get_name(),
                    'product_url' => $product->is_visible() ? $product->get_permalink() : '',
                    'download_name' => $file['name'],
                    'order_id' => $order->get_id(),
                    'order_key' => $order->get_order_key(),
                    'downloads_remaining' => $file['downloads_remaining'],
                    'access_expires' => $file['access_expires'],
                    'file' => array(
                        'name' => $file['name'],
                        'file' => $file['file'],
                    ),
                );
            }
        }
    }
}
 
// Change Order-Language back to origin
update_post_meta($order->get_id(), 'wpml_language', $current_order_wpml_language);