I have the following code on my site which sends a 'Ready to Collect' email to my customers, as well as updating the order status to ready to collect.
function custom_status_action( $actions ) {
unset($actions['send_osm_email_ready-to-collect']);
$actions['ns_fba_send_to_fulfillment'] = __( 'Send Ready to Collect custom email', 'woocommerce' );
return $actions;
}
add_action( 'woocommerce_order_actions', 'custom_status_action', 999 );
function ns_fba_send_to_fulfillment_process( $order ) {
$wc_emails = WC()->mailer()->get_emails();
if( empty( $wc_emails ) ) return;
$email_id = "wc_order_status_email_6181";
foreach ( $wc_emails as $wc_mail ) {
if ( $wc_mail->id == $email_id ) {
$wc_mail->trigger( $order->get_id() );
}
}
// update order status
$order->update_status( 'wc-ready' );
$order->save();
}
add_action( 'woocommerce_order_action_ns_fba_send_to_fulfillment', 'ns_fba_send_to_fulfillment_process' );
Works flawlessly - but I want to duplicate this for another order action 'Order has been collected'.
I'm not a developer, coder, and have extremely little knowledge of php - but presume by changing the reference from ready to collect to my new order status AND updating the order status email number, then this should work? However I'm stumped as to how to find the order status email number (of the email I've already created). Any tips please?