Skip Navigation

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 1 reply, has 2 voices.

Last updated by Bruno 4 years, 6 months ago.

Assisted by: Bruno.

Author Posts
October 22, 2019 at 6:16 pm

Menno

I am trying to: get all translations of variations

Link to a page where the issue can be seen: hidden link

I expected to see: variation IDs of ALL translations

Instead, I got: 2 translations, english language missing. However, the English language is only showing the variation IDs of the english language. However, the German, Dutch and English languages are all connected. Weird eh?

My code:

global $sitepress;
$trid = $sitepress->get_element_trid($variation['variation_id']);
$translations = $sitepress->get_element_translations($trid);

foreach ($translations as $translation):
echo '<pre>';
print_r($translation->element_id);
echo '</pre>';;
endforeach;

October 23, 2019 at 7:26 pm #4814199

Bruno

Thank you for contacting us. Where exactly is the problem happening? When I access the link you posted above I can't see the problem. In my test environment, I tested the following code:

add_action( 'init', function() {
	// variation ID
	$variation_test = 140;

	$trid = apply_filters( 'wpml_element_trid', null, $variation_test, 'post_product_variation');
	$translations = apply_filters( 'wpml_get_element_translations', null, $trid, 'post_product_variation' );

	var_dump( $translations );
} );

This correctly returned the element data. Have you tried to check if the problem persists with all non-WPML plugins (except WooCommerce) disabled?

Filters:
- https://wpml.org/wpml-hook/wpml_element_trid/
- https://wpml.org/wpml-hook/wpml_get_element_translations/

Thank you.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.