Skip to content

Instantly share code, notes, and snippets.

@zorem
Created November 6, 2019 05:54
Show Gist options
  • Save zorem/f19322c1534689b8b9e5d4e52feb0a38 to your computer and use it in GitHub Desktop.
Save zorem/f19322c1534689b8b9e5d4e52feb0a38 to your computer and use it in GitHub Desktop.
Code snippet for send SMS using Twilio SMS Notifications plugin when shipment status has changed from TrackShip
<?php
add_action( 'ast_trigger_ts_status_change', 'ast_send_status_change_sms_twillio', 10, 3 );
function ast_send_status_change_sms_twillio($order_id, $old_status, $new_status){
$wc_ast_api_key = get_option('wc_ast_api_key');
$blog_title = get_bloginfo();
if ( !is_plugin_active( 'woo-advanced-shipment-tracking/woocommerce-advanced-shipment-tracking.php' ) ) {
return;
}
if( !$wc_ast_api_key ){
return;
}
if( $old_status != $new_status){
$new_status = apply_filters( "trackship_status_filter", $new_status );
$message = 'Hi there. we thought you’d like to know that your recent order - #'.$order_id.' from '.$blog_title.' is '.$new_status.'.';
$sms_notification = new WC_Twilio_SMS_Notification($order_id);
$sms_notification->send_manual_customer_notification($message);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment