Skip to content

Instantly share code, notes, and snippets.

@zorem
Last active April 19, 2022 12:45

Revisions

  1. zorem revised this gist Apr 19, 2022. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions wc_twilio_sms_compatibility.php
    Original file line number Diff line number Diff line change
    @@ -20,7 +20,7 @@ function ast_pro_wc_twilio_sms_message_replacement( $message, $order ) {
    if ( 'completed' == $order_status || 'shipped' == $order_status ) {
    if ( count( $tracking_items ) > 0 ) {
    foreach ( $tracking_items as $key => $tracking_item ) {
    $message .= sprintf( wp_kses( __( "Your order was shipped with %s and your tracking code is: <a href='%s'>%s</a>", 'ast-pro' ), array( 'a' => array( 'href' => array() ) ) ), $tracking_item['formatted_tracking_provider'], $tracking_item['ast_tracking_link'], $tracking_item['tracking_number'] );
    $message .= sprintf( __( "Your order was shipped with %s and your tracking code is: %s", 'ast-pro' ), $tracking_item['formatted_tracking_provider'], $tracking_item['tracking_number'] );
    }
    }
    }
    @@ -29,11 +29,11 @@ function ast_pro_wc_twilio_sms_message_replacement( $message, $order ) {
    if ( 'partial-shipped' == $order_status ) {
    if ( count( $tracking_items ) > 0 ) {
    foreach ( $tracking_items as $key => $tracking_item ) {
    $message .= sprintf( wp_kses( __( "Your order was Partially Shipped with %s and your tracking code is: <a href='%s'>%s</a>", 'ast-pro' ), array( 'a' => array( 'href' => array() ) ) ), $tracking_item['formatted_tracking_provider'], $tracking_item['ast_tracking_link'], $tracking_item['tracking_number'] );
    $message .= sprintf( __( "Your order was Partially Shipped with %s and your tracking code is: %s", 'ast-pro' ), $tracking_item['formatted_tracking_provider'], $tracking_item['tracking_number'] );
    }
    }
    }
    //echo $message;exit;

    return $message;
    }
    }
  2. zorem revised this gist Apr 19, 2022. 1 changed file with 7 additions and 4 deletions.
    11 changes: 7 additions & 4 deletions wc_twilio_sms_compatibility.php
    Original file line number Diff line number Diff line change
    @@ -9,15 +9,18 @@ function ast_pro_wc_twilio_sms_message_replacement( $message, $order ) {
    }

    $order_id = $order->get_id();
    $order_status = $order->get_status();

    $order_status = $order->get_status();

    $tracking_items = ast_get_tracking_items($order_id);

    //echo '<pre>';print_r($tracking_items);echo '</pre>';

    //You can comment this condition if you don't want to add tracking information on completed order status SMS message.
    if ( 'completed' == $order_status || 'shipped' == $order_status ) {
    if ( count( $tracking_items ) > 0 ) {
    foreach ( $tracking_items as $key => $tracking_item ) {
    $message .= sprintf( __( "Your order was shipped with %s and your tracking code is: %s", 'ast-pro' ), $tracking_item['formatted_tracking_provider'], $tracking_item['tracking_number'] );
    $message .= sprintf( wp_kses( __( "Your order was shipped with %s and your tracking code is: <a href='%s'>%s</a>", 'ast-pro' ), array( 'a' => array( 'href' => array() ) ) ), $tracking_item['formatted_tracking_provider'], $tracking_item['ast_tracking_link'], $tracking_item['tracking_number'] );
    }
    }
    }
    @@ -26,11 +29,11 @@ function ast_pro_wc_twilio_sms_message_replacement( $message, $order ) {
    if ( 'partial-shipped' == $order_status ) {
    if ( count( $tracking_items ) > 0 ) {
    foreach ( $tracking_items as $key => $tracking_item ) {
    $message .= sprintf( __( "Your order was Partially Shipped with %s and your tracking code is: %s", 'ast-pro' ), $tracking_item['formatted_tracking_provider'], $tracking_item['tracking_number'] );
    $message .= sprintf( wp_kses( __( "Your order was Partially Shipped with %s and your tracking code is: <a href='%s'>%s</a>", 'ast-pro' ), array( 'a' => array( 'href' => array() ) ) ), $tracking_item['formatted_tracking_provider'], $tracking_item['ast_tracking_link'], $tracking_item['tracking_number'] );
    }
    }
    }

    //echo $message;exit;
    return $message;
    }
    }
  3. zorem revised this gist Apr 19, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion wc_twilio_sms_compatibility.php
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@ function ast_pro_wc_twilio_sms_message_replacement( $message, $order ) {
    return;
    }

    $order_id = $order->get_order_number();
    $order_id = $order->get_id();
    $order_status = $order->get_status();

    $tracking_items = ast_get_tracking_items($order_id);
  4. zorem revised this gist Apr 13, 2022. 1 changed file with 4 additions and 6 deletions.
    10 changes: 4 additions & 6 deletions wc_twilio_sms_compatibility.php
    Original file line number Diff line number Diff line change
    @@ -4,22 +4,20 @@
    if ( !function_exists( 'ast_pro_wc_twilio_sms_message_replacement' ) ) {
    function ast_pro_wc_twilio_sms_message_replacement( $message, $order ) {

    if ( !class_exists( 'WC_Advanced_Shipment_Tracking_Actions' ) ) {
    if ( !function_exists( 'ast_get_tracking_items' ) ) {
    return;
    }

    $order_id = $order->get_order_number();
    $order_status = $order->get_status();

    if ( function_exists( 'ast_get_tracking_items' ) ) {
    $tracking_items = ast_get_tracking_items($order_id);
    }
    $tracking_items = ast_get_tracking_items($order_id);

    //You can comment this condition if you don't want to add tracking information on completed order status SMS message.
    if ( 'completed' == $order_status || 'shipped' == $order_status ) {
    if ( count( $tracking_items ) > 0 ) {
    foreach ( $tracking_items as $key => $tracking_item ) {
    $message .= sprintf( __( "Your order was shipped with %s and your tracking code is: %s", 'woo-advanced-shipment-tracking' ), $tracking_item['formatted_tracking_provider'], $tracking_item['tracking_number'] );
    $message .= sprintf( __( "Your order was shipped with %s and your tracking code is: %s", 'ast-pro' ), $tracking_item['formatted_tracking_provider'], $tracking_item['tracking_number'] );
    }
    }
    }
    @@ -28,7 +26,7 @@ function ast_pro_wc_twilio_sms_message_replacement( $message, $order ) {
    if ( 'partial-shipped' == $order_status ) {
    if ( count( $tracking_items ) > 0 ) {
    foreach ( $tracking_items as $key => $tracking_item ) {
    $message .= sprintf( __( "Your order was Partially Shipped with %s and your tracking code is: %s", 'woo-advanced-shipment-tracking' ), $tracking_item['formatted_tracking_provider'], $tracking_item['tracking_number'] );
    $message .= sprintf( __( "Your order was Partially Shipped with %s and your tracking code is: %s", 'ast-pro' ), $tracking_item['formatted_tracking_provider'], $tracking_item['tracking_number'] );
    }
    }
    }
  5. zorem created this gist Apr 2, 2021.
    38 changes: 38 additions & 0 deletions wc_twilio_sms_compatibility.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    /* add AST tracking info in customer SMS using Twilio SMS Notifications plugin */
    add_filter( 'wc_twilio_sms_customer_sms_before_variable_replace', 'ast_pro_wc_twilio_sms_message_replacement', 10, 2 );

    if ( !function_exists( 'ast_pro_wc_twilio_sms_message_replacement' ) ) {
    function ast_pro_wc_twilio_sms_message_replacement( $message, $order ) {

    if ( !class_exists( 'WC_Advanced_Shipment_Tracking_Actions' ) ) {
    return;
    }

    $order_id = $order->get_order_number();
    $order_status = $order->get_status();

    if ( function_exists( 'ast_get_tracking_items' ) ) {
    $tracking_items = ast_get_tracking_items($order_id);
    }

    //You can comment this condition if you don't want to add tracking information on completed order status SMS message.
    if ( 'completed' == $order_status || 'shipped' == $order_status ) {
    if ( count( $tracking_items ) > 0 ) {
    foreach ( $tracking_items as $key => $tracking_item ) {
    $message .= sprintf( __( "Your order was shipped with %s and your tracking code is: %s", 'woo-advanced-shipment-tracking' ), $tracking_item['formatted_tracking_provider'], $tracking_item['tracking_number'] );
    }
    }
    }

    //You can comment this condition if you don't want to add tracking information on Partially Shipped order status SMS message.
    if ( 'partial-shipped' == $order_status ) {
    if ( count( $tracking_items ) > 0 ) {
    foreach ( $tracking_items as $key => $tracking_item ) {
    $message .= sprintf( __( "Your order was Partially Shipped with %s and your tracking code is: %s", 'woo-advanced-shipment-tracking' ), $tracking_item['formatted_tracking_provider'], $tracking_item['tracking_number'] );
    }
    }
    }

    return $message;
    }
    }