Skip Navigation

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

Problem:
You are experiencing a mismatch between Product ID and Variation ID in your ERP system due to WPML's handling of translations, which assigns unique IDs for translated products and their variations.
Solution:
We recommend using WPML’s built-in API or hooks to translate secondary language variation IDs back to the main language IDs before exporting to your ERP. For example, you can use the following code to fetch the main language ID for a product variation:

$original_id = apply_filters( 'wpml_object_id', $variation_id, 'product_variation', true, 'en' );

Please note that such customization falls outside the standard support scope. If you need help implementing this, consider hiring a professional developer from WPML Contractors.

If this solution does not apply to your case, or if it seems outdated, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If issues persist, please open a new support ticket at WPML support forum.

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.

Tagged: 

This topic contains 3 replies, has 0 voices.

Last updated by Bruno Kos 2 weeks, 6 days ago.

Assisted by: Bruno Kos.

Author Posts
December 4, 2024 at 9:51 am #16475543

Alex Arama

Background of the issue:
I am trying to resolve a Product ID and Variation ID mismatch issue as described in this topic: https://wpml.org/forums/topic/product-id-and-variation-id-mismatch-causing-issues/. I attempted the solution recommended in the topic but couldn't find the specific code: if ('product_variation' === get_post_type($item->get_product_id())).

Symptoms:
The product variation IDs in orders are not the main language ones (English), causing a mismatch with our ERP.

Questions:
Did anything change in the meantime?
Is there another way to solve this?

December 4, 2024 at 1:36 pm #16477025

Bruno Kos
Supporter

Languages: English (English ) German (Deutsch ) French (Français )

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

Hi,

Thank you for contacting WPML support!

This behavior is expected when using WPML in WordPress. WPML handles products and their variations as individual entities in each language, assigning unique IDs for translated products and their variations. Since your ERP system expects product variation IDs to match the main language (English in your case), the difference in IDs across translations will cause a mismatch.

What if you try to Use WPML’s built-in API or hooks to translate secondary language variation IDs back to the main language IDs before exporting to your ERP?

For example, use the wpml_object_id function to fetch the main language ID for a product variation.

$original_id = apply_filters( 'wpml_object_id', $variation_id, 'product_variation', true, 'en' );

However note that such customization is not within the support scope as you would be modifying default WPML behaviour.

You can check with our https://wpml.org/contractors/ on achieving such functionality.

Regards,
Bruno Kos

December 4, 2024 at 4:07 pm #16477814

Alex Arama

Hi Bruno

Thanks for your feedback and availability to help me.

Unfortunately I have no idea how to use your suggestion. Maybe you could provide me with a more instruction.

However, I see that there is at least one other similar case already solved with one of your colleague's help (https://wpml.org/forums/topic/product-id-and-variation-id-mismatch-causing-issues/) and it would be lovely to be able to use a similar updated solution.

Regards
Alex

December 5, 2024 at 3:23 pm #16482534

Bruno Kos
Supporter

Languages: English (English ) German (Deutsch ) French (Français )

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

The issue described in https://wpml.org/forums/topic/product-id-and-variation-id-mismatch-causing-issues/ was not a custom code. It was a bug identified in WooCommerce Multilingual & Multicurrency which was eventually resolved.

The steps to reproduce the issue were as follows:

1. Purchase a variable product in a secondary language.
2. Go to **WordPress Dashboard > WooCommerce > Orders**.
3. Check the product name in the order—it does not display the purchased product variations.
4. When following the same steps in the default language, the variations are correctly included in the product title within the order.

In your case, however, this seems to be related to custom work. The code you are using to send data to your ERP needs to account for the difference in translated product and variation IDs between WordPress and WPML. These differences are an inherent part of how WPML handles translations.

As this falls outside the scope of standard support, I recommend reaching out to a professional developer through WPML Contractors https://wpml.org/contractors/.