Woocommerce 如何在电子商务电子邮件中显示属性

Woocommerce 如何在电子商务电子邮件中显示属性,woocommerce,Woocommerce,我想在woocoomerce的所有电子邮件通知中显示产品属性。我使用了此代码,但它显示的属性与订单产品不匹配。知道如何修复它以显示corect属性吗?谢谢你 // Show additional intormation into mail notification - make a shortcode if ( ! function_exists( 'display_product_additional_information' ) ) { function display_pro

我想在woocoomerce的所有电子邮件通知中显示产品属性。我使用了此代码,但它显示的属性与订单产品不匹配。知道如何修复它以显示corect属性吗?谢谢你

// Show additional intormation into mail notification - make a shortcode 

if ( ! function_exists( 'display_product_additional_information' ) ) {

    function display_product_additional_information($atts) {

        // Shortcode attribute (or argument)
        $atts = shortcode_atts( array(
            'id'    => ''
        ), $atts, 'product_additional_information' );

        // If the "id" argument is not defined, we try to get the post Id
        if ( ! ( ! empty($atts['id']) && $atts['id'] > 0 ) ) {
           $atts['id'] = get_the_id();
        }

        // We check that the "id" argument is a product id
        if ( get_post_type($atts['id']) === 'product' ) {
            $product = wc_get_product($atts['id']);
        }
        // If not we exit
        else {
            return;
        }

        ob_start(); // Start buffering

        do_action( 'woocommerce_product_additional_information', $product );

        return ob_get_clean(); // Return the buffered outpout
    }

    add_shortcode('product_additional_information', 'display_product_additional_information');

}

// Show additional intormation into mail notification 

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 ){
    $product = $item->get_product();

    // Handling product variations
    if( $product->is_type('variation') )
        $product = wc_get_product( $item->get_product_id() );

    // Display the product additional information
    echo do_shortcode("[product_additional_information]");
}