【发布时间】:2021-07-22 06:33:00
【问题描述】:
基于Add the product description to WooCommerce email notifications 的回答,如何在两个电子邮件通知中添加产品简短描述而不是产品描述(往往更长)?
【问题讨论】:
标签: php wordpress woocommerce orders email-notifications
基于Add the product description to WooCommerce email notifications 的回答,如何在两个电子邮件通知中添加产品简短描述而不是产品描述(往往更长)?
【问题讨论】:
标签: php wordpress woocommerce orders 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 文件中。它应该可以工作。
【讨论】: