Add text string in front of subject on New Order mail on local pickup.
/*
* Add text string in front of subject on New Order mail.
*/
function twstudio_change_admin_email_subject( $subject, $order ) {
global $woocommerce;
$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
$subject = sprintf( '[%s] Ny kundeordre (# %s) - %s', $blogname, $order->id, $order->order_date );
$shipping_method = @array_shift($order->get_shipping_methods());
if ( $shipping_method ) {
$shipping_method_id = $shipping_method['method_id'];
// local_pickup
if ( strpos($shipping_method_id, 'local_pickup' ) !== false ) {
$subject = sprintf( 'CUSTOM TEXT [%s] Ny kundeordre (%s) - %s', $blogname, $order->id, $order->get_date_created()->format ('d.m.Y') );
}
}
return $subject;
}
add_filter('woocommerce_email_subject_new_order', 'twstudio_change_admin_email_subject', 1, 2);