Hi there,

I wanted to add a woocommerce email notification for “order shipped”.

I really don’t know PHP very well, although I got this code from this reference:
> https://www.businessbloomer.com/woocommerce-send-custom-email/#comments

> Ive enabled PHP code block everywhere and i can’t see any result in the email settings of woocommerce to show that the code has worked..

Really Appreciate your Support!!
Oli

 

<?php
function wpblog_wc_register_post_statuses() {
register_post_status( ‘wc-shipped’, array(
‘label’ => _x( ‘Shipped’, ‘WooCommerce Order status’, ‘text_domain’ ),
‘public’ => true,
‘exclude_from_search’ => false,
‘show_in_admin_all_list’ => true,
‘show_in_admin_status_list’ => true,
‘label_count’ => _n_noop( ‘Approved (%s)’, ‘Approved (%s)’, ‘text_domain’ )
) );
}
add_filter( ‘init’, ‘wpblog_wc_register_post_statuses’ );
 
function wpblog_wc_add_order_statuses( $order_statuses ) {
$order_statuses[‘wc-shipped’] = _x( ‘Shipped’, ‘WooCommerce Order status’, ‘text_domain’ );
return $order_statuses;
}
add_filter( ‘wc_order_statuses’, ‘wpblog_wc_add_order_statuses’ );
 
/**
* @snippet Send Formatted Email @ WooCommerce Custom Order Status
* @how-to Get CustomizeWoo.com FREE
* @sourcecode https://businessbloomer.com/?p=91907
* @author Rodolfo Melogli
* @compatible WooCommerce 3.5.7
* @donate $9 https://businessbloomer.com/bloomer-armada/
*/
 
// Targets custom order status “shipped”
// Uses ‘woocommerce_order_status_’ hook
 
add_action( ‘woocommerce_order_status_shipped’, ‘bbloomer_status_custom_notification’, 20, 2 );
 
function bbloomer_status_custom_notification( $order_id, $order ) {
 
$heading=’Order Shipped’;
$subject=’Order Shipped’;
 
// Get WooCommerce email objects
$mailer= WC()->mailer()->get_emails();
 
// Use one of the active emails e.g. “Customer_Completed_Order”
// Wont work if you choose an object that is not active
// Assign heading & subject to chosen object
$mailer[‘WC_Email_Customer_Completed_Order’]->heading =$heading;
$mailer[‘WC_Email_Customer_Completed_Order’]->settings[‘heading’]=$heading;
$mailer[‘WC_Email_Customer_Completed_Order’]->subject =$subject;
$mailer[‘WC_Email_Customer_Completed_Order’]->settings[‘subject’]=$subject;
 
// Send the email with custom heading & subject
$mailer[‘WC_Email_Customer_Completed_Order’]->trigger($order_id);
 
// To add email content use https://businessbloomer.com/woocommerce-add-extra-content-order-email/
// You have to use the email ID chosen above and also that $order->get_status() == “shipped”
 
}
?>

One response to “Issue Creating “order shipped” status email in Woocommerce – in php “child theme””

  1. cmsexpertss says:

    Hi,

    Thank you for contacting us.

    Regarding your request, please share your site access so that I can check it there.

    Regards,
    Muhammad Osama

Leave a Reply

Your email address will not be published.