【发布时间】:2022-01-08 04:45:08
【问题描述】:
我已经编写了这个函数来在 WooCommerce 的订单接收页面上显示类别和类别 ID。
但是,我希望禁止在 WooCommerce 订单电子邮件中显示此内容。有什么建议吗?
// Display order items product categories and ids
add_action( 'woocommerce_order_item_meta_end', 'display_custom_data_in_emails', 10, 4 );
function display_custom_data_in_emails( $item_id, $item, $order, $bool ) {
// Get the product categories for this item
$terms = wp_get_post_terms( $item->get_product_id(), 'product_cat', array( 'fields' => 'names' ) );
$term_ids = wp_get_post_terms( $item->get_product_id(), 'product_cat', array('fields' => 'ids') );
// Output a coma separated string of product category names
echo "<br><small>" . implode(', ', $terms) . "</small>";
echo "<br><small>" . implode(', ', $term_ids) . "</small>";
}
}
【问题讨论】:
标签: wordpress woocommerce hook-woocommerce email-notifications