Woocommerce Short_Description在详细信息顺序中 [英] Woocommerce Short_Description in Details Order
本文介绍了Woocommerce Short_Description在详细信息顺序中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在用Wordpress和Woocommerce创建我的新网站.我想在订单明细中显示简短说明.
I'm creating my new website with Wordpress and Woocommerce. I would like to display the short description in the order detail.
我找到了以下代码:
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?
推荐答案
这可以通过将自定义功能钩在woocommerce_order_item_name
过滤器挂钩中来完成,方法是:
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>';
}
此代码会出现在您活动的子主题(或主题)的function.php文件中,也可能会出现在任何插件文件中.
经过测试,可以正常工作.它将在项目名称下方的订购项目"中显示简短描述.
Tested and works. It will display the short description in Order items below the item name.
这篇关于Woocommerce Short_Description在详细信息顺序中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文