WooCommerce - 将产品简短描述添加到已完成的订单电子邮件

WooCommerce - Add product Short Description to completed order email

我想在给客户的 completed-order 电子邮件中的产品标题下方添加一个产品简短描述。谢谢!

试试这个:

// Show product description in email notifications
add_action( 'woocommerce_order_item_meta_end', 'woo_completed_order_email_notification', 10, 4 );

function woo_completed_order_email_notification( $item_id, $item, $order = null, $plain_text = false ){
    // Only on email notifications
    if( is_wc_endpoint_url() ) return;

    if ($order &&  $order->get_status() == 'completed' ) { // change status accordingly

        $product = wc_get_product( $item->get_product_id() );
        $short_desc = $product->get_short_description();

        
        if( ! empty($short_desc) ) {
            // Display the product description
            echo '<div class="product-description"><p>' . $short_desc . '</p></div>';
        }
    }
}