Php 针对WooCommerce客户处理和已完成的订单电子邮件通知

Php 针对WooCommerce客户处理和已完成的订单电子邮件通知,php,wordpress,woocommerce,orders,email-notifications,Php,Wordpress,Woocommerce,Orders,Email Notifications,我正在尝试在服务器上的订单表之后添加自定义内容 “处理订单”和“订单完成”客户电子邮件,使用以下代码 只有当客户选择“本地提货”作为运输方式时,才应添加此选项 function local_pickup_extra_content_email($order, $is_admin_email) { if ( $is_admin_email ) { return; } if ( ICL_LANGUAGE_CODE == "he" && str

我正在尝试在服务器上的订单表之后添加自定义内容 “处理订单”和“订单完成”客户电子邮件,使用以下代码

只有当客户选择“本地提货”作为运输方式时,才应添加此选项

function local_pickup_extra_content_email($order, $is_admin_email) {
    if ( $is_admin_email ) {
        return;
    }

    if ( ICL_LANGUAGE_CODE == "he" && strpos( $order->get_shipping_method(), 'Local Pickup' ) !== false) {
        echo '<p><strong>Note:</strong> Please wait for telephone confirmation of local pickup.</p>';
    }
}

add_action( 'woocommerce_email_after_order_table', 'local_pickup_extra_content_email', 10, 2  );
function local\u picku\u extra\u content\u email($order$is\u admin\u email){
如果($is_admin_email){
返回;
}
如果(ICL_语言_代码==“he”&&strpos($order->get_shipping_方法(),'Local Pickup')!==false){
echo'注意:请等待电话确认本地取货。

'; } } 添加操作('WOOMerce\u email\u在订单表之后,'local\u picku\u extra\u content\u email',10,2);
未将内容添加到指定的电子邮件中。它仅添加到通过Woocommerce订单管理页面手动发送的“订单详细信息/发票”电子邮件中

我如何将上述内容添加到提到的电子邮件中?我做错了什么?

(电子邮件模板不会在主题文件夹中被覆盖)

通过缺少钩子参数
$email
,可以轻松地针对这些电子邮件通知执行此操作,方法如下:

add_action( 'woocommerce_email_after_order_table', 'local_pickup_extra_content_email', 10, 4  );
function local_pickup_extra_content_email( $order, $sent_to_admin, $plain_text, $email ) {
    // Only for "Processing Order" and "Order Completed" customer emails
    if( ! ( 'customer_processing_order' == $email->id || 'customer_completed_order' == $email->id ) ) return;

    $lang = get_post_meta( $order->id, 'wpml_language', true );
    if ( $lang == 'he' && && strpos( $order->get_shipping_method(), 'Local Pickup' ) !== false) {
        echo '<p><strong>Note:</strong> Please wait for telephone confirmation of local pickup.</p>';
    }
}
add_action('woocommerce_email_在_order_table_之后,'local_picku_extra_content_email',10,4);
功能本地接收额外内容电子邮件($order,$sent,$admin,$plain,$email){
//仅适用于“处理订单”和“订单完成”客户电子邮件
如果(!('customer_processing_order'=$email->id | | customer_completed_order'==$email->id))返回;
$lang=get\u post\u meta($order->id,'wpml\u language',true);
if($lang=='he'&&&&strpos($order->get\u shipping\u method(),'Local Pickup')!==false){
echo'注意:请等待电话确认本地取货。

'; } }
这段代码位于活动子主题(或主题)的function.php文件或任何插件文件中

测试和工作



类似的回答:

这不起作用,因为if语句中的WPML条件:

ICL_LANGUAGE_CODE == "he" 
我认为Woocommerce发送电子邮件时不存在ICL_语言代码。为了解决这个问题,我将上面问题中的if语句替换为以下语句,它就像一个符咒:

$lang = get_post_meta( $order->id, 'wpml_language', true );
if ( $lang == 'he' && && strpos( $order->get_shipping_method(), 'Local Pickup' ) !== false) {
    echo '<p><strong>Note:</strong> Please wait for telephone confirmation of local pickup.</p>';
}
$lang=get\u post\u meta($order->id,'wpml\u language',true);
if($lang=='he'&&&&strpos($order->get\u shipping\u method(),'Local Pickup')!==false){
echo'注意:请等待电话确认本地取货。

'; }
谢谢您的回答。这不起作用,因为我的WPML条件:
ICL\u语言\u代码==“he”
我猜在发送电子邮件时,ICL\u语言\u代码不存在。为了解决这个问题,我用下面的代码替换了上面的代码行,它工作起来很有魅力:
$lang=get\u post\u meta($order->id,'wpml\u language',true)
如果($lang=='he'&&&…){
我花了很长时间在谷歌上找到了处理订单id挂钩,谢谢。