基于 Woocommerce 中的运输方式的不同电子邮件标题
Different email heading based on shipping methods in Woocommerce
所以我想在 WooCommerce 中发送标题略有不同的同一封电子邮件。它使用参数 $email_heading
变量来保存当前电子邮件标题的值,所以我认为一个简单的替换就可以了。它没有。我可能完全错过了这里的标记,非常感谢任何帮助。
我想说当您选择本地拾取时,他们可以在选择其他运输时选择您的订单,然后将默认值(然后存储了WooCommerce的电子邮件设置)。
add_filter( "woocommerce_email_heading_customer_completed_order", 'HDM_woocommerce_email_header', 10, 2 );
function HDM_woocommerce_email_header( $email_heading, $email ) {
if ('customer_completed_order' == $email->id && $order->has_shipping_method('local_pickup') ){
$order_id = $order->get_id();
$email_heading = '<h1>Your Order Is Ready For Pickup</h1>';
}
return $email_heading;
};
您的代码中有一些错误,例如 $email
实际上是 $order
。此外,您已经在此复合挂钩中定位 customer_completed_order
,因此您不需要在 IF
语句中使用它……
所以试试:
add_filter( "woocommerce_email_heading_customer_completed_order", 'custom_email_heading', 10, 2 );
function custom_email_heading( $email_heading, $order ) {
if ( $order->has_shipping_method('local_pickup') ){
$email_heading = '<h1>Your Order Is Ready For Pickup</h1>';
}
return $email_heading;
}
代码进入您的活动子主题(或活动主题)的 function.php 文件。已测试并有效。
我想知道这是否适用于电子邮件主题:
add_filter( "woocommerce_email_subject_customer_completed_order", 'custom_email_subject', 10, 2 );
function custom_email_subject( $subject, $order ) {
if ( $order->has_shipping_method('local_pickup') ){
$subject = 'Your Order Is Ready For Pickup';
}
return $subject;
}
所以我想在 WooCommerce 中发送标题略有不同的同一封电子邮件。它使用参数 $email_heading
变量来保存当前电子邮件标题的值,所以我认为一个简单的替换就可以了。它没有。我可能完全错过了这里的标记,非常感谢任何帮助。
我想说当您选择本地拾取时,他们可以在选择其他运输时选择您的订单,然后将默认值(然后存储了WooCommerce的电子邮件设置)。
add_filter( "woocommerce_email_heading_customer_completed_order", 'HDM_woocommerce_email_header', 10, 2 );
function HDM_woocommerce_email_header( $email_heading, $email ) {
if ('customer_completed_order' == $email->id && $order->has_shipping_method('local_pickup') ){
$order_id = $order->get_id();
$email_heading = '<h1>Your Order Is Ready For Pickup</h1>';
}
return $email_heading;
};
您的代码中有一些错误,例如 $email
实际上是 $order
。此外,您已经在此复合挂钩中定位 customer_completed_order
,因此您不需要在 IF
语句中使用它……
所以试试:
add_filter( "woocommerce_email_heading_customer_completed_order", 'custom_email_heading', 10, 2 );
function custom_email_heading( $email_heading, $order ) {
if ( $order->has_shipping_method('local_pickup') ){
$email_heading = '<h1>Your Order Is Ready For Pickup</h1>';
}
return $email_heading;
}
代码进入您的活动子主题(或活动主题)的 function.php 文件。已测试并有效。
我想知道这是否适用于电子邮件主题:
add_filter( "woocommerce_email_subject_customer_completed_order", 'custom_email_subject', 10, 2 );
function custom_email_subject( $subject, $order ) {
if ( $order->has_shipping_method('local_pickup') ){
$subject = 'Your Order Is Ready For Pickup';
}
return $subject;
}