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: Compatibility
This topic contains 8 replies, has 0 voices.
Last updated by David Gaitan 1 month, 4 weeks ago.
Assisted by: David Gaitan.
| Author | Posts |
|---|---|
| February 25, 2026 at 7:43 am #17849723 | |
|
yekdalK |
I have set the custom meta for stock as copy and manually update one product and the value synced in other languages related to stock now problem is i have 5000+ product how to do this |
| February 25, 2026 at 9:23 pm #17853036 | |
|
David Gaitan Supporter Languages: English (English ) Spanish (Español ) Timezone: America/Managua (GMT-06:00) |
Hello Yekdal, I am David Gaitan from the WPML dev team. I am here to help you with your request. Before start helping you let me ensure I'm understanding it well: You have changed the `_stock` custom field to Copy, and then tested the translation on a product and you got the expected behavior, correct? And now, your problem is that you have +5000 products where you need to update this `_stock` value among the languages, correct? If all this is true, could you please if you rolled back the setting for `_stock` from Copy to Don't Translate as the AI assistant requested you? Best, |
| February 26, 2026 at 5:07 am #17853366 | |
|
yekdalK |
Hi there Yes, I would like to bulk update the _stock quantity for all products. Following the AI assistant’s suggested method is not feasible or optimal for our case. Could you please provide a code-based solution or a setting that would allow us to achieve this more efficiently? As per the current configuration, the values are set as follows: Note: Please treat this as an urgent issue, as the website is live and we require a solution as soon as possible. Thank you. |
| February 27, 2026 at 4:57 am #17858554 | |
|
David Gaitan Supporter Languages: English (English ) Spanish (Español ) Timezone: America/Managua (GMT-06:00) |
Hi Yekdal, I have good news. Our plugin that integrates WPML with WooCommerce already has a functionality to syncronize these values. Let's go ahead with it but first, please create a backup before, just in case the result is not what you're expecting. Please go to WooCommerce > WCML, then select the "Status" tab. You'll see at the bottom of this section a link that says "Troubleshooting" (see screenshots to follow steps). Once you are on this Troubleshooting page, please select the option "Synchronize stock for products and product variations", then scroll to the bottom and click on "Run the selected tools". It will start the sync and you just will need to wait for it to finish. Please let me know if you have any question. Please also let men know if this solved your issue. Best, |
| February 27, 2026 at 12:54 pm #17859780 | |
|
yekdalK |
Hi there We have followed all the steps as per your instructions; however, the stock is still not synced. Please review the screenshots below: Note: We have already cleared the cache, so this does not appear to be a caching issue. |
| February 27, 2026 at 9:02 pm #17861135 | |
|
David Gaitan Supporter Languages: English (English ) Spanish (Español ) Timezone: America/Managua (GMT-06:00) |
Hello Yekdal, Thank you for running the syncronizer. It's really odd that you are still seeing issues there. At this moment is a bit hard to give you guidance without seeing exactly what you have in your site. Having said this, it would be great to know if you agree with sharing temporary access to your site, so we can take a better look at your site and have better clues. If you agree to this, please don't share access on this comment box because is public. Please do that by adding credentials on the form that you'll see below this form. It will ensure that access is private and only us will be able to see it. Thank you, |
| March 2, 2026 at 4:08 pm #17865610 | |
|
David Gaitan Supporter Languages: English (English ) Spanish (Español ) Timezone: America/Managua (GMT-06:00) |
Hello Yekdal. Thank you for sharing the access, this is really helpful. I have reviewed your site and have noticed that stock is correctly but only for Simple Product (not for variations). We'll need to take a look at the WCML plugin to check what's happening exactly with the stock sync for variable products. For now, I have a code snippet that can solve the problem and this is by adding this code snippet to the theme functions.php file and run the syncronizer again (By going WooCommerce > WCML > Status > Troubleshooting and check the sync stock for producst, as I explained on my previous replies). THis is the code snippet: add_action( 'wcml_synchronize_product_component', function ( $product, $translationsIds, $translationsLanguages, $componentName ) {
// Only run for variations and only for the Stock component.
if ( ! $product || $product->post_type !== 'product_variation' || $componentName !== 'stock' ) {
return;
}
if ( empty( $translationsIds ) ) {
return;
}
$product_id = (int) $product->ID;
$wc_product = wc_get_product( $product_id );
if ( ! $wc_product ) {
return;
}
// Same logic as WCML Stock component: who actually holds the stock?
$id_managing_stock = $wc_product->get_stock_managed_by_id();
$translation_ids_for_stock = $translationsIds;
if ( $id_managing_stock !== $product_id ) {
// Parent manages stock: sync parent's _stock to parent's translations.
global $wpml_post_translations;
if ( ! $wpml_post_translations ) {
return;
}
$translation_ids_for_stock = $wpml_post_translations->get_element_translations( $id_managing_stock, false, false );
if ( empty( $translation_ids_for_stock ) ) {
return;
}
// $translation_ids_for_stock may be [ lang => id ]; we need a flat list of IDs.
$translation_ids_for_stock = array_values( array_filter( array_map( 'intval', $translation_ids_for_stock ) ) );
}
// Sync _stock from source to its translations.
$source_stock = get_post_meta( $id_managing_stock, '_stock', true );
if ( $source_stock !== '' && $source_stock !== null ) {
foreach ( $translation_ids_for_stock as $tid ) {
if ( $tid === $id_managing_stock ) {
continue;
}
update_post_meta( $tid, '_stock', $source_stock );
}
}
// Sync _stock_status from this variation to its variation translations.
$source_status = get_post_meta( $product_id, '_stock_status', true );
if ( $source_status !== '' && $source_status !== null ) {
foreach ( $translationsIds as $tid ) {
if ( (int) $tid === $product_id ) {
continue;
}
update_post_meta( $tid, '_stock_status', $source_status );
}
}
// Clear caches so WooCommerce sees the new values.
delete_transient( 'wc_low_stock_count' );
delete_transient( 'wc_outofstock_count' );
if ( function_exists( 'wcml_product_data_store_cpt' ) ) {
$wcml_data_store = wcml_product_data_store_cpt();
if ( $wcml_data_store && method_exists( $wcml_data_store, 'update_lookup_table_data' ) ) {
foreach ( array_merge( [ $product_id ], $translationsIds ) as $pid ) {
wp_cache_delete( $pid, 'post_meta' );
wp_cache_delete( 'product-' . $pid, 'products' );
$wcml_data_store->update_lookup_table_data( $pid );
}
}
}
}, 11, 4 );
I highly recommend run a database backup before and then run the syncronizer (with the snippet in the theme functions) Please let me know if you need help with this. I'm happy to help you. You just need to confirm that have a backup ready. Thanks, |
| March 5, 2026 at 8:05 am #17873889 | |
|
yekdalK |
Hi there The issue is resolved, now may I remove the code you have provided? |
| March 5, 2026 at 1:00 pm #17874967 | |
|
David Gaitan Supporter Languages: English (English ) Spanish (Español ) Timezone: America/Managua (GMT-06:00) |
Hello Yekdal, I am happy to hear that issue was resolved! Regarding your question, yes! You can remove it. Please remember that this is a temporary fix and I already reported the issue to the team that develops the compatibility plugin with WooCommerce and they will introduce the fix on a next release. So, this code won't be necessary anymore. If you have any question, I am here to help! Thanks, |

