Skip to content

Instantly share code, notes, and snippets.

@zorem
Last active June 23, 2020 07:04
Show Gist options
  • Save zorem/f3c400bf73fd22a1cefe9e4cc29cb03f to your computer and use it in GitHub Desktop.
Save zorem/f3c400bf73fd22a1cefe9e4cc29cb03f to your computer and use it in GitHub Desktop.
Code snippet for send SMS using Twilio SMS Notifications plugin when shipments status change 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 ( !class_exists( 'WC_Advanced_Shipment_Tracking_Actions' ) ) {
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.'.';
if ( class_exists( 'WC_Twilio_SMS_Notification' ) ) {
$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