Woocommerce: Display Product Variation Description on order page

痞子三分冷 提交于 2019-12-06 23:42:34

I finally found a solution that worked here now showing the variation description on the order page and the order email.

add_filter( 'woocommerce_order_item_name', 'display_product_title_as_link', 10, 2 );
function display_product_title_as_link( $item_name, $item ) {

    $_product = get_product( $item['variation_id'] ? $item['variation_id'] : $item['product_id'] );

    $link = get_permalink( $_product->id );

    $_var_description ='';

    if ( $item['variation_id'] ) {
        $_var_description = $_product->get_variation_description();
    }

    return '<a href="'. $link .'"  rel="nofollow">'. $item_name .'</a><br>'. $_var_description ;
}

It puts the variations description right below the title, but that works for me.

Finally found a solution that worked Problem solved, add this to child theme function.php:

add_filter( 'woocommerce_product_variation_title_include_attributes', '__return_false' );
add_filter( 'woocommerce_order_item_name', 'display_product_description', 10, 2 );
    function display_product_description( $item_name, $item ) {

        $_product = get_product( $item['variation_id'] ? $item['variation_id'] : $item['product_id'] );


        $_var_description ='';

        if ( $item['variation_id'] ) {
            $_var_description = $_product->get_variation_description();
        }

        return $_var_description ;
    }

Try this in you theme's functions.php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!