【发布时间】:2021-12-07 12:13:24
【问题描述】:
我想添加一个自定义列,以在 wooCommerce 的订单历史记录表中显示产品类别
我找到了如何添加自定义列,但我似乎无法在此列中显示与订单相关联的分类产品。
对于这个例子,我只有 1 个产品,但如果我可以显示多个税款,那就更好了。
这是我发现的(来自:skyverge 博客)添加一个新列:
/**
* Adds a new column to the "My Orders" table in the account.
*
* @param string[] $columns the columns in the orders table
* @return string[] updated columns
*/
function sv_wc_add_my_account_orders_column( $columns ) {
$new_columns = array();
foreach ( $columns as $key => $name ) {
$new_columns[ $key ] = $name;
// add ship-to after order status column
if ( 'order-number' === $key ) {
$new_columns['order-ship-to'] = __( 'Catégorie', 'textdomain' );
}
}
return $new_columns;
}
add_filter( 'woocommerce_my_account_my_orders_columns', 'sv_wc_add_my_account_orders_column' );
欢迎指点
【问题讨论】:
标签: wordpress woocommerce product orders taxonomy-terms