Woocommerce – display product attribute value next to title in order email

Question

I didn’t get answer on SO: https://stackoverflow.com/questions/68801425/woocommerce-display-specific-product-attribute-value-next-to-title-in-order-em

I found this filter that hooks SKU to the product title in orders and emails:

function sku_before_order_item_name( $item_name, $item, $is_visible ) {     
    $product = $item->get_product();
    $sku = $product->get_sku();

    // When sku doesn't exist we exit
    if( empty( $sku ) ) return $item_name;

    $sku_text = __( 'SKU', 'woocommerce' ) . ': ' . $sku;

    // Add product permalink when argument $is_visible is true
    $product_permalink =  $is_visible ? $product->get_permalink( $item ) : '';

    if( $product_permalink )
        return sprintf( '<a href="%s">%s - %s</a>', $product_permalink, $sku_text, $item->get_name() );
    else
        return $item->get_name() . ' - ' . $sku_text;
}
add_filter( 'woocommerce_order_item_name', 'sku_before_order_item_name', 30, 3 );

But how can I add a specific product attribute pa_cislo-skla value from product attributes table instead of SKU?

Single-product view - additional info tab
Email view

0
Juraj 1 month 2021-08-16T07:13:30-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse