Woocommerce Short_Description in Details Order

 ̄綄美尐妖づ 提交于 2020-08-23 07:56:29

问题


I'm creating my new website with Wordpress and Woocommerce. I would like to display the short description in the order detail.

I found this code :

add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_single_excerpt', 5);

But that shows me the description in home.

Is there a way to make it appear in the order detail?


回答1:


It can be done with a custom unction hooked in woocommerce_order_item_name filter hook, this way:

add_filter( 'woocommerce_order_item_name', 'add_single_excerpt_to_order_item', 10, 3 );
function add_single_excerpt_to_order_item( $item_name, $item, $is_visible ){
    $product_id = $item->get_product_id(); // Get the product Id
    $excerpt = get_the_excerpt( $product_id ); // Get the short description

    return $item_name . '<br><p class="item-description">' . $excerpt ; '</p>';
}

This code goes in function.php file of your active child theme (or theme) or also in any plugin file.

Tested and works. It will display the short description in Order items below the item name.



来源:https://stackoverflow.com/questions/47908299/woocommerce-short-description-in-details-order

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