Skip to content Skip to sidebar

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

Problem:
If you're experiencing issues with WooCommerce Product Options not translating product options and 'Estimated Total' in the cart when using the Greek language on your WooCommerce site, this might be due to the plugin storing untranslated option names and choice labels in the cart meta.
Solution:
We recommend trying the following workaround. First, ensure you back up your website completely. Then, add the following code to your theme's functions.php file:

add_filter( 'woocommerce_add_cart_item_data', 'my_wpo_translate_cart_meta_with_wpml', 20, 4 );<br />function my_wpo_translate_cart_meta_with_wpml( $cart_item_data, $product_id, $variation_id, $quantity ) {<br />  if ( empty( $cart_item_data['wpo_options'] ) ) {<br />    return $cart_item_data;<br />  }<br />  if ( ! class_exists( '\Barn2\Plugin\WC_Product_Options\Plugin_Factory' ) ||<br />      ! class_exists( '\Barn2\Plugin\WC_Product_Options\Integration\WPML' ) ||<br />      ! class_exists( '\Barn2\Plugin\WC_Product_Options\Model\Option' ) ) {<br />    return $cart_item_data;<br />  }<br />  $plugin = \Barn2\Plugin\WC_Product_Options\Plugin_Factory::create( '', '' );<br />  $wpml_integration = new \Barn2\Plugin\WC_Product_Options\Integration\WPML( $plugin );<br />  foreach ( $cart_item_data['wpo_options'] as $option_id => &$option_data ) {<br />    $option = \Barn2\Plugin\WC_Product_Options\Model\Option::find( $option_data['option_id'] ?? 0 );<br />    if ( ! $option ) {<br />      continue;<br />    }<br />    $translated_name = $wpml_integration->translate_string( $option->name, $option, 'option_name' );<br />    $option_data['name'] = $translated_name;<br />    if ( empty( $option_data['choice_data'] ) || empty( $option->choices ) ) {<br />      continue;<br />    }<br />    $index_by_id = [];<br />    foreach ( $option->choices as $idx => $choice ) {<br />      if ( isset( $choice['id'] ) ) {<br />        $index_by_id[ $choice['id'] ] = $idx;<br />      }<br />    }<br />    $values = is_array( $option_data['value'] ) ? $option_data['value'] : [ $option_data['value'] ];<br />    foreach ( $option_data['choice_data'] as $i => &$choice_data ) {<br />      if ( ! isset( $choice_data['label'] ) ) {<br />        continue;<br />      }<br />      if ( empty( $index_by_id ) ) {<br />        continue;<br />      }<br />      $value_for_this_choice = $values[ $i ] ?? null;<br />      if ( ! isset( $index_by_id[ $value_for_this_choice ] ) ) {<br />        continue;<br />      }<br />      $choice_index = $index_by_id[ $value_for_this_choice ];<br />      $original_label = $option->choices[ $choice_index ]['label'];<br />      $choice_data['label'] = $wpml_integration->translate_string( $original_label, $option, 'choice_label', $choice_index );<br />    }<br />  }<br />  return $cart_item_data;<br />}

Please note, this workaround has limitations, such as not re-translating labels if the language is changed after products are added to the cart. For a permanent fix, we will need to contact Barn2 for an update to their integration.

If this solution does not resolve your issue or seems irrelevant due to being outdated or not applicable to your case, 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 18 replies, has 1 voice.

Last updated by Otto 5 months, 2 weeks ago.

Assisted by: Otto.

Author Posts
November 25, 2025 at 7:05 pm #17609621

jeanneK

Thank you Otto,

I have sent your workaround to our developer and I will let you know once he has implemented it and we have tested it.

Presumably this will need to be deleted once Barn2 fix the issue?

With many thanks,

Jeanne

November 25, 2025 at 7:49 pm #17609668

Otto

Hello,

Great, thanks, keep me posted please.

Yes, once the issue is fixed in the plugin code, this workaround should be removed.

Best Regards,
Otto

November 26, 2025 at 4:25 pm #17612879

jeanneK

Hello Otto,

That all seems to be working fine now.
Thank you.
I have advised Barn2 - you may wish to contact them too.

With thanks and with every good wish,

Jeanne

November 26, 2025 at 4:50 pm #17612923

Otto

Hello Jeanne,

I am glad to hear that.

I reported the issue to our compatibility team, and they'll reach the author too.

I am closing the ticket, if you have any other issue, please don't hesitate to reach us again.

Best Regards,
Otto