Skip to content

Instantly share code, notes, and snippets.

@dartrax
dartrax / functions.php
Last active September 29, 2022 19:14
Translate WooCommerce and WooCommerce Germanized mails into order language with TranslatePress before sending. Note: As of TranslatePress Version 2.3.5, this functionality was implemented natively by TranslatePress, making this Code obsolete. Read more here: https://translatepress.com/docs/translating-woocommerce-emails/
// Save the current language in post_meta when checkout is processed (used to identify correct Email language)
add_action('woocommerce_checkout_update_order_meta', 'dartrax_save_language_on_checkout', 10, 2 );
function dartrax_save_language_on_checkout( $order_id, $posted ) {
if( ! class_exists('TRP_Translate_Press') ) return '';
global $TRP_LANGUAGE;
update_post_meta( $order_id, 'order_language', $TRP_LANGUAGE );
}
// Woocommerce Germanized Mails
add_action( 'woocommerce_gzd_shipment_status_draft_to_shipped_notification', 'dartrax_prepare_locale_for_Mail_with_shipment_id', 5, 1 );
@dartrax
dartrax / functions.php
Last active February 26, 2024 12:18
Translate WooCommerce mails into order language with TranslatePress before sending. Note: As of TranslatePress Version 2.3.5, this functionality was implemented natively by TranslatePress, making this Code obsolete. Read more here: https://translatepress.com/docs/translating-woocommerce-emails/
// Save the current language in post_meta when checkout is processed (used to identify correct Email language)
add_action('woocommerce_checkout_update_order_meta', 'dartrax_save_language_on_checkout', 10, 2 );
function dartrax_save_language_on_checkout( $order_id, $posted ) {
if( ! class_exists('TRP_Translate_Press') ) return '';
global $TRP_LANGUAGE;
update_post_meta( $order_id, 'order_language', $TRP_LANGUAGE );
}
// Woocommerce Shipment Mails
add_action( 'woocommerce_order_status_processing_to_cancelled_notification','dartrax_prepare_locale_for_Mail_with_order_id', 5, 1 );