如何根据产品ID添加自定义文本电子邮件?
例如,我需要根据产品ID添加不同的文本
我找到了此代码,但只在订单表之前应用了该代码,我需要在所需的位置应用该代码:
add_action( 'woocommerce_email_before_order_table', 'email_before_order_table_conditional_display', 20, 4 );
function email_before_order_table_conditional_display( $order, $sent_to_admin, $plain_text, $email ) {
// Only for "commpeted" order status notification
if ( 'customer_completed_order' !== $email->id ) return;
foreach( $order->get_items() as $item ){
if( has_term( "Gifts", "product_cat", $item->get_product_id() ) ){
echo '<p class="email-text-conditional">Thank you for your order with Adventure Clues, we have sent your recipient the gift card.</p>';
break;
}
if( has_term( "Clothes", "product_cat", $item->get_product_id() ) ){
echo '<p class="email-text-conditional">Thank you for your order with Adventure Clues, we are managing your Clothes.</p>';
break;
}
}
}```