Support

Search results for ""

Sorry, no results found. Perhaps you would like to search the documentation?
All Topics
Adrian Mörchen

[WPML, WooCommerce] Prices not synced when using Inline Edit

Hello,

When using Inline Edit to update product prices the price is not update in the translation as well.
Probably some required hooks are not fired internally.

Error

Thanks

Adrian

2 weeks, 5 days ago
Stefan van den Dungen Gronovius
Developer

Hi,

Thanks for the screenshot! That made it easy to reproduce the issue.

Admin Columns Pro doesn’t have a dedicated WPML integration, but you can solve this with a small code snippet using a hook that runs after every inline or bulk edit.

The issue is that WPML normally copies prices to translations when you save a product through the WooCommerce product editor. Inline editing saves the product directly through WooCommerce, so WPML doesn’t trigger that synchronization and the translations keep their old prices.

The snippet below hooks into ac/editing/saved and tells WPML to synchronize fields configured as “Copy”, including regular and sale prices. It then triggers WooCommerce Multilingual to update the related product data and caches.

add_action('ac/editing/saved', function ($column, $id) {
$post_type = get_post_type($id);

if ( ! in_array($post_type, ['product', 'product_variation'], true)) {
return;
}

$original_id = (int) apply_filters('wpml_original_element_id', $id, $id, 'post_' . $post_type) ?: $id;

do_action('wpml_sync_all_custom_fields', $original_id);

$product = get_post($original_id);

if ('product_variation' === $post_type) {
$product = get_post($product->post_parent);
}

do_action('wcml_synchronize_product_translations', $product, [], []);
}, 10, 2);

 

You can add this to your theme’s functions.php or use a plugin like Code Snippets.

Make sure to edit prices in the original language, as WPML synchronizes translations from the original product.

Let me know if this works for you!

2 weeks, 4 days ago