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 | |
| // Filter to exclude phone number in the Klaviyo Webhook. | |
| add_filter('exclude_klaviyo_phone', 'klaviyo_phone_number' ); | |
| function klaviyo_phone_number( $bool ){ | |
| $bool = true; | |
| return $bool; | |
| } |
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 | |
| // Hook into the custom action 'ts_status_change_trigger' to trigger our callback function when the Shipment status changes. | |
| add_action('ts_status_change_trigger', 'status_change_callback', 8, 4 ); | |
| // Define the callback function that is triggered when the action fires. | |
| function status_change_callback( $order_id, $old_status, $new_status, $tracking_number ) { | |
| // Fetch the WooCommerce order object using the provided order ID. | |
| $order = wc_get_order( $order_id ); | |
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 | |
| // This line adds a filter to modify the estimated delivery date format. | |
| add_filter( 'est_delivery_date_format', 'est_delivery_date_format_callback' ); | |
| // This is the callback function that will be triggered when the filter 'est_delivery_date_format' is applied. | |
| function est_delivery_date_format_callback( $date_format ) { | |
| $custom_date_format = 'l, M d, Y'; // Define a custom date format here. | |
| return $custom_date_format; // Return the custom date format. This will be used to format the estimated delivery date. | |
| } |
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 | |
| // This code snippet adds a filter to control email recipients for a specific status. | |
| // Use the 'add_multiple_emails_to_shipment_email' filter hook to modify recipient email addresses. | |
| add_filter( 'add_multiple_emails_to_shipment_email', 'add_email_address', 10, 2 ); | |
| function add_email_address( $email_to, $new_status ) { | |
| // Check if the status is 'exception' to determine whether to send the email to the admin only. | |
| if ( 'exception' == $new_status ) { | |
| // Override the recipient email array to send the exception email to the admin. | |
| $email_to = ['info@youstore.com']; // Replace with the admin's email address. |
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 | |
| // This code snippet ensures that whenever a customer is notified about a shipment status change (e.g., "Return to Sender"), a copy of the same notification is also sent to the store admin (or multiple email addresses). You can customize the status and email addresses to suit your store's needs. | |
| // Customize the shipment status and admin email addresses as needed. | |
| add_filter( 'add_multiple_emails_to_shipment_email', 'customize_email_recipients', 10, 2 ); | |
| function customize_email_recipients( $email_to, $new_status ) { | |
| // Replace 'return_to_sender' with the desired status to trigger the admin email notification. | |
| if ( 'return_to_sender' == $new_status ) { | |
| $email_to[] = 'info@yourstore.com'; // Add admin recipients here. | |
| // Example: $email_to[] = 'support@yourstore.com'; |
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 Schedule action for Klaviyo intergration when Shipment status change | |
| */ | |
| add_action( 'trackship_shipment_status_trigger', 'ts_status_change_callback', 10, 4 ); | |
| function ts_status_change_callback ( $order_id, $old_status, $new_status, $tracking_number ) { | |
| $timestamp = time() + 3; | |
| $hook = 'klaviyo_hoook'; | |
| $args = array( | |
| 'order_id' => $order_id, |
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_filter( 'trackship_tracking_event', 'remove_text_tracking_event', 10, 1 ); | |
| /** | |
| * Remove specified text in the tracking event. | |
| * | |
| * @param string $tracking_event The tracking event | |
| * | |
| * @return string The modified tracking event | |
| */ |
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_filter( 'trackship_tracking_event', 'replace_text_tracking_event', 10, 1 ); | |
| /** | |
| * Replaces specified text in the tracking event. | |
| * | |
| * @param string $tracking_event The tracking event | |
| * | |
| * @return string The modified tracking event | |
| */ |
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 | |
| /** | |
| * | |
| * To modify the order status of a WooCommerce order in response to a shipment status change, | |
| * you’ll also need to introduce a custom order status for automated delivery processing. To achieve this, | |
| * insert the following code snippet into the functions.php file of your currently active WordPress theme. | |
| * Available shipment statuses slug: 'in_transit', 'available_for_pickup', 'out_for_delivery', 'failure', 'on_hold', 'exception', 'return_to_sender', 'delivered' | |
| * | |
| */ | |
| add_action( 'ts_status_change_trigger', 'ts_status_change_trigger', 10, 4 ); |
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 email address for Shipment email will be sent to multiple email address. | |
| add_filter( 'add_multiple_emails_to_shipment_email', 'add_email_address' ); | |
| function add_email_address( $email_to ) { | |
| $email_to[] = '{admin_email}'; // Email will be sent to Store admin. | |
| $email_to[] = 'info@youstore.com'; | |
| return $email_to; | |
| } |
NewerOlder