Add shipped status on order status change and when status changed to shipped email notification will be send to billing email address. I tried more and more articles, Please help. I need more explanation from this one.
Asked
Active
Viewed 3,492 times
1
-
Please see below link. It will helpful for you. https://stackoverflow.com/questions/24016489/send-email-from-woocommerce-when-order-status-is-changed-to-a-custom-order-statu – Gufran Hasan Feb 16 '18 at 05:16
-
Did you checked my below code?? – developerme Feb 16 '18 at 06:59
-
Yes i checked the code. – Ansaf Ans Feb 16 '18 at 10:20
1 Answers
6
Please use below code in your functions.php
Register Shipped Order Status in WooCommerce
/**
* Add custom status to order list
*/
add_action( 'init', 'register_custom_post_status', 10 );
function register_custom_post_status() {
register_post_status( 'wc-shipped', array(
'label' => _x( 'Shipped', 'Order status', 'woocommerce' ),
'public' => true,
'exclude_from_search' => false,
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,
'label_count' => _n_noop( 'Shipped <span class="count">(%s)</span>', 'Shipped <span class="count">(%s)</span>', 'woocommerce' )
) );
}
/**
* Add custom status to order page drop down
*/
add_filter( 'wc_order_statuses', 'custom_wc_order_statuses' );
function custom_wc_order_statuses( $order_statuses ) {
$order_statuses['wc-shipped'] = _x( 'Shipped', 'Order status', 'woocommerce' );
return $order_statuses;
}
Here is the code for ending email to custom order status
add_action('woocommerce_order_status_changed', 'shipped_status_custom_notification', 10, 4);
function shipped_status_custom_notification( $order_id, $from_status, $to_status, $order ) {
if( $order->has_status( 'shipped' )) {
// Getting all WC_emails objects
$email_notifications = WC()->mailer()->get_emails();
// Customizing Heading and subject In the WC_email processing Order object
$email_notifications['WC_Email_Customer_Processing_Order']->heading = __('Your Order shipped','woocommerce');
$email_notifications['WC_Email_Customer_Processing_Order']->subject = 'Your {site_title} order shipped receipt from {order_date}';
// Sending the customized email
$email_notifications['WC_Email_Customer_Processing_Order']->trigger( $order_id );
}
}
add_action( 'woocommerce_order_status_wc-shipped', array( WC(), 'send_transactional_email' ), 10, 1 );
add_filter( 'woocommerce_email_actions', 'filter_woocommerce_email_actions' );
function filter_woocommerce_email_actions( $actions ){
$actions[] = 'woocommerce_order_status_wc-shipped';
return $actions;
}

developerme
- 1,845
- 2
- 15
- 34
-
1Thank you, It's working but i am getting an email "Thank you for your order ". I didn't get order shipped email. Is there any ways to change email template.? – Ansaf Ans Feb 16 '18 at 10:16
-
-
Hi I am using this code and works fine the only problem is that my header and subject actually don't change ? Thanks in advance. – Aljaz May 22 '20 at 18:00
-
Me too. I got thank you for your order, but not the shipping template. Any clue why? – Manthan_Admane May 07 '21 at 20:27