我已经配置了:
Product
|– Attribute
|– Taxonomy
|- Term 1
|- Term 2
|- Term 3
如果该商品具有“条款1”,则发送并通过电子邮件添加带有该类型od产品说明的部分。如果没有Term,则使用其他指令。
有人知道该怎么做吗?
答案 0 :(得分:0)
好的。我相信,当客户从您的站点订购产品时,根据该产品可用的期限,您必须在发送的邮件中添加一些其他数据。如果是这样,那么我可以指导您采取正确的方法。考虑客户新订单电子邮件。电子邮件模板中有不同的挂钩。您可以检查它post
在我使用钩子时,woocommerce_email_after_order_table
function render_custom_section_to_email($order, $sent_to_admin, $plain_text, $email){
foreach ($order->get_items() as $item_id => $item) {
// You get each product you added to the order
// Check if the item has term
$product_id = $item->get_product_id(); // Get the product ID
$terms = get_the_terms( $product_id, 'taxonamy_name' ); // Get all terms of custom taxonamy of product
if('check_if_$terms_contain_the_required_term'){ // If true
echo 'Your content Here';
}
}
}
add_action('woocommerce_email_after_order_table', 'render_custom_section_to_email', 10, 4);
您可以对此功能进行一些更改以使工作正常。尤其是在if条件下