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 3 replies, has 2 voices.

Last updated by remiG-4 11 months ago.

Assigned support staff: Rohan Sadanandan.

Author Posts
July 1, 2019 at 9:33 am #4116933

milosS-2

I am trying to: Generate PDF Invoice on language which is selected in custom filed wpml_language = en (default language of site is SR), but PDF invoice is always on Serbian language, when I change default language of site to be English, PDF Invoice will be on Englise. I think that custom field value for wpml_language doesn't work. This functionality already worked and we have updated versions od WMPL and PDF generator, could you please check and help us?

Link to a page where the issue can be seen: this is issue with creating PDF invoice in Woocommerce

I expected to see: PDF Invoice on selected language which is in field wpml_language

Instead, I got: I got PDF invoice on default site language

July 1, 2019 at 9:56 am #4117605

milosS-2

My issue is resolved now. Thank you!

December 20, 2019 at 9:24 am #5169531

remiG-4

Hi milosS-2, can you let me know how you solved your issue ? Ho you test the value of the wpml_language metadata ?
Thanks!

December 20, 2019 at 10:35 am #5169879

remiG-4

I found... for information:

/**
* Add a custom meta data (admin custom field) in an order
* Voir "The 2016 way:" https://stackoverflow.com/questions/25626058/add-extra-meta-for-orders-in-woocommerce
*/
add_action('woocommerce_checkout_update_order_meta',function( $order_id, $posted ) {
update_post_meta( $order_id, 'my_tracking_number', '-----' );
} , 10, 2);

/**
* Add a custom field (in an order) to the emails https://docs.woocommerce.com/document/add-a-custom-field-in-an-order-to-the-emails/
*/
add_filter( 'woocommerce_email_order_meta_fields', 'custom_woocommerce_email_order_meta_fields', 10, 3 );
function custom_woocommerce_email_order_meta_fields( $fields, $sent_to_admin, $order )
{
if (get_post_meta($order->get_id(), 'wpml_language', true) == 'fr' ){
echo "<h2 style=\"color: #0F55A5\">Votre numéro de suivi</h2> ".get_post_meta($order->get_id(), 'my_tracking_number', true)."<br><br>";
}
elseif(get_post_meta($order->get_id(), 'wpml_language', true) == 'it'){
echo "<h2 style=\"color: #0F55A5\">Il tuo numero di tracking</h2> ".get_post_meta($order->get_id(), 'my_tracking_number', true)."<br><br>";
}
elseif(get_post_meta($order->get_id(), 'wpml_language', true) == 'es'){
echo "<h2 style=\"color: #0F55A5\">Su número de seguimiento</h2> ".get_post_meta($order->get_id(), 'my_tracking_number', true)."<br><br>";
}
elseif(get_post_meta($order->get_id(), 'wpml_language', true) == 'de'){
echo "<h2 style=\"color: #0F55A5\">Ihre Trackingnummer</h2> ".get_post_meta($order->get_id(), 'my_tracking_number', true)."<br><br>";
}
else {
echo "<h2 style=\"color: #0F55A5\">Your tracking number</h2> ".get_post_meta($order->get_id(), 'my_tracking_number', true)."<br><br>";
}

}