【发布时间】:2018-11-03 02:59:39
【问题描述】:
我需要有关 woocommerce 自定义电子邮件挂钩的帮助。
每当产品完成时,我都会尝试根据产品 ID 发送不同的电子邮件。
我的代码不起作用,如下:
/**************
DIFFERENT MESSAGES FOR DIFFERENT PRODUCTS
****************/
//hook our function to the new order email
add_action('woocommerce_email_order_details', 'uiwc_email_order_details_products', 1, 4);
function uiwc_email_order_details_products($order, $admin, $plain, $email) {
$status = $order->get_status();
// checking if it's the order status we want
if ( $status == "completed" ) {
$items = $order->get_items();
if ( $item['product_id'] == "3181") {
echo __( '<strong>IMPORTANT - NEXT STEP:</strong><br>To get started, please follow <a href="https:XXXXX">this link</a> to complete the Policies form.<br><br>This is a really important first step, and only takes about 5 minutes. After completeing the Policies form, you will receive additional instructions on next steps.<br><br>Congratulations! Let your journey begin.<br><br>', 'uiwc' );
}
elseif ( $item['product_id'] == "3223") {
echo __( '<strong>IMPORTANT - NEXT STEP:</strong><br>Differnet product so differenct email....<br><br>', 'uiwc' );
}
}
}
非常感谢任何建议
【问题讨论】:
-
欢迎来到 SO。在寻求帮助时,重要的是不仅要说“这不起作用”,还要解释您的预期结果是什么以及您的代码产生的结果与此有何不同。请阅读stackoverflow.com/help/how-to-ask
-
你说的产品已经完成是什么意思?你的意思是订单完成了吗?
-
@Nick(这对 SO 有效吗?)感谢您的建议。下次我将在我的问题陈述中更具描述性。感谢您的耐心等待。
-
@melvin 在重新阅读我的问题后,你是对的 - 这没有意义。不过你确实猜到了,我的意思是订单完成时。
标签: php wordpress woocommerce orders email-notifications