【发布时间】:2022-02-16 20:40:15
【问题描述】:
有许多主题涉及“WooCommerce 电子邮件中的自定义字段”主题,但我找不到我正在努力解决的确切案例。
我可以实现这个项目的 50% 以在订单表中将字段显示为元。
add_action( 'woocommerce_order_item_meta_end', 'custom_product_info', 20, 4 );
function custom_product_info ( $item_id, $item, $order, $plain_text ) {
$id = $item->get_product_id();
$erlebnisidgc = get_field('erlebnis_id',$id);
if($erlebnisidgc){
echo "<p>Here's your Link</p><a href=https://b-ceed.de/?eventid='.$erlebnisidgc'>Testlink</a>";
}
}
因此,此代码与自定义字段完美配合。 问题是此输出不仅显示在customer_completed_order 电子邮件中,而且还显示在所有其他电子邮件中。
因此,我尝试了这段代码sn-p:
add_action( 'woocommerce_order_item_meta_end', 'custom_product_info', 20, 4 );
function custom_product_info ( $item_id, $item, $order, $plain_text ) {
if ( $email->id == 'customer_completed_order' ) {
$id = $item->get_product_id();
$erlebnisidgc = get_field('erlebnis_id',$id);
if($erlebnisidgc){
echo "<p>Here's your Link</p><a href=https://b-ceed.de/?eventid='.$erlebnisidgc'>Testlink</a>";
}
}
}
但是现在输出将不再显示在任何电子邮件中,并且会触发内部服务器错误。有什么建议吗?
【问题讨论】:
标签: wordpress woocommerce advanced-custom-fields email-notifications