Last active
June 23, 2020 07:04
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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