Skip to content

Instantly share code, notes, and snippets.

@xadapter xadapter/functions.php
Last active Jan 6, 2020

Embed
What would you like to do?
Translate shipment tracking message with Polylang Pro and WooCommerce Shipment Tracking Plugin: https://www.pluginhive.com/product/woocommerce-shipment-tracking-pro/
add_filter('wf_custom_tracking_message', 'update_tracking_message', 10, 3);
function update_tracking_message($current_msg, $language, $order) {
global $wpdb;
$qry = "SELECT term_taxonomy_id FROM {$wpdb->prefix}term_relationships WHERE object_id = $order->ID ORDER BY object_id DESC";
$values = $wpdb->get_results($qry, ARRAY_A);
$post_lang_choice = 'en';
if (!empty($values)) {
$land_id = $values[0]['term_taxonomy_id'];
$qryl = "SELECT slug FROM {$wpdb->prefix}terms WHERE term_id = $land_id ";
$valuesl = $wpdb->get_results($qryl, ARRAY_A);
if (!empty($valuesl))
$post_lang_choice = $valuesl[0]['slug'];
}
if ($post_lang_choice == 'fr') {
//change your language here if needed, for German can use 'de'
return "Votre commande a été expédiée le [DATE] via [SERVICE]. Pour suivre les envois, veuillez suivre le lien correspondant aux numéros d'expédition [ID]";
} else {
return "Your order was shipped on [DATE] via [SERVICE]. To track shipment, please follow the link of ID(s) [ID]";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.