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.

This topic contains 2 replies, has 2 voices.

Last updated by Ellery 6 years ago.

Assigned support staff: Andreas Neuber.

Author Posts
July 5, 2013 at 8:13 am #141852

Ellery

WP: 3.5.2
WPML: 2.8.2
Woocommerce: 2.0.12
Woocomemerce Multilingual: 2.3.2

I am trying to fetch the product name from an order, based on the language I define.

For example, a customer checkout in English, and I would like to get the Italian product name using PHP.

However, the product name is not in string translation. And I also looked at the icl_t function, it did not give me any hints.

Can you please tell me how can I do this?

Thanks in advance.

July 5, 2013 at 9:09 am #141872

Andreas Neuber
Supporter

Languages: English (English ) German (Deutsch )

Hello Ellery,

Products in Woocommerce are custom posts and the names of the products in the original language and there translations are recorded in table "wp_posts".
To link the original post and its translations together we have the records in database table "wp_icl_translations".

Before I give you any specialized PHP code, allow me to ask, do you want to improve the view under "WooCommerce > Orders" in the backend?

--
echo get_the_title( icl_object_id( $id, 'product', false, 'lang-code' ) );

July 9, 2013 at 8:57 am #142768

Ellery

Thank you so much. This line of your code:

echo get_the_title( icl_object_id( $post_id, 'product', false, 'zh-hant' ) );

just work!

By the way, I do not quite understand what your question means. May I ask if you can explain a little bit?

Thank you again.