基于Add the product description to WooCommerce email notifications答案,如何在两封电子邮件通知中添加产品简短描述而不是产品描述(通常较长)?
最佳答案
要显示发送给管理员的电子邮件通知的简短说明,请使用以下命令:
// Displaying short product description in email notifications sent to admin
add_action( 'woocommerce_order_item_meta_end', 'product_description_in_new_email_notification', 10, 4 );
function product_description_in_new_email_notification( $item_id, $item, $order = null, $plain_text = false ){
// Only on email notifications
if( is_wc_endpoint_url() ) return;
$product_obj = wc_get_product( $item->get_product_id() );
$short_descr = $product_obj->get_short_description();
if( ! empty($short_descr) ) {
// Display the product description
echo '<div class="product-description"><p>' . $short_descr . '</p></div>';
}
}
代码位于事件子主题(或事件主题)的functions.php 文件中。它应该可以工作。
关于php - 将产品简短描述添加到 WooCommerce 电子邮件通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67308073/