[Resolved] Product ID and Variation ID mismatch causing issues
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:
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.
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?
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.
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/.