1

所以我想在 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;
    };
4

2 回答 2

1

$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 文件中。测试和工作。

于 2018-11-21T04:14:34.677 回答
0

我想知道这是否对电子邮件主题有效:

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;
}
于 2021-12-21T10:37:54.457 回答