Overview of the Issue
In SMS Alert Order Notifications – WooCommerce, customers who order in a secondary language get the order SMS in your site’s default language.
Workaround
Until SMS Alert fixes it, you can send the order SMS in the order’s language:
- Go to WPMLSettings, open Custom XML Configuration, add this and save:
<wpml-config> <admin-texts> <key name="smsalert_message"> <key name="sms_body_*" /> </key> </admin-texts> </wpml-config> - Go to WPMLString Translation and translate the SMS templates (domain admin_texts_smsalert_message).
- Add this code to your theme’s
functions.phpfile, or with a code snippets plugin. It builds the customer SMS in the language of the order:add_action( 'woocommerce_order_status_changed', function ( $order_id ) { $order = wc_get_order( $order_id ); $lang = $order ? $order->get_meta( 'wpml_language' ) : ''; if ( $lang ) { $GLOBALS['sms_alert_wpml_previous_lang'] = apply_filters( 'wpml_current_language', null ); do_action( 'wpml_switch_language', $lang ); } }, 9 ); add_action( 'woocommerce_order_status_changed', function () { if ( isset( $GLOBALS['sms_alert_wpml_previous_lang'] ) ) { do_action( 'wpml_switch_language', $GLOBALS['sms_alert_wpml_previous_lang'] ); unset( $GLOBALS['sms_alert_wpml_previous_lang'] ); } }, 11 );