在Woocommerce的我的帐户订单表中显示产品描述 [英] display product description in my account orders table of Woocommerce
本文介绍了在Woocommerce的我的帐户订单表中显示产品描述的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只想在订单ID旁边显示第一项的说明,因此,如果有3个项目并且所有项目都有说明,我希望它在订单ID旁边仅显示第一项的说明. /p>
通常:#3214
我期望的是:#3214 |产品说明
解决方案
在活动主题的functions.php中添加以下代码片段以完成上述操作-
function modify_woocommerce_order_number( $order_id, $order ) {
if( !is_wc_endpoint_url( 'orders' ) ) return $order_id;
$first_line_item_descrp = '';
foreach ( $order->get_items( 'line_item' ) as $item_id => $item ) {
$product = $item->get_product();
$first_line_item_descrp = $product->get_description();
break;
}
return $order_id . ' | ' . $first_line_item_descrp;
}
add_filter( 'woocommerce_order_number', 'modify_woocommerce_order_number', 99, 2 );
I want to display the description of the first item only next to the order id so if there is 3 items and all of them have descriptions i want it to show next to the order id the description of the first item only.
Normally: #3214
What i expect: #3214 | Product Description
解决方案
Add the follows code snippet in your active theme's functions.php to dothe above -
function modify_woocommerce_order_number( $order_id, $order ) {
if( !is_wc_endpoint_url( 'orders' ) ) return $order_id;
$first_line_item_descrp = '';
foreach ( $order->get_items( 'line_item' ) as $item_id => $item ) {
$product = $item->get_product();
$first_line_item_descrp = $product->get_description();
break;
}
return $order_id . ' | ' . $first_line_item_descrp;
}
add_filter( 'woocommerce_order_number', 'modify_woocommerce_order_number', 99, 2 );
这篇关于在Woocommerce的我的帐户订单表中显示产品描述的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文