1 回答
TA贡献1773条经验 获得超3个赞
您的代码中存在一些错误和缺失的内容,请尝试以下操作:
add_filter( 'manage_edit-shop_order_columns', 'add_custom_columns_to_admin_orders', 20);
function add_custom_columns_to_admin_orders( $columns ) {
$new_columns = array();
foreach ( $columns as $column_name => $column_info ) {
$new_columns[ $column_name ] = $column_info;
if ( 'order_total' === $column_name ) {
$new_columns['order_shipping'] = __( 'Tarnemeetod', 'my-textdomain' );
$new_columns['order_payment'] = __( 'Maksemeetod', 'my-textdomain' );
}
}
return $new_columns;
}
add_action( 'manage_shop_order_posts_custom_column', 'custom_columns_content_in_admin_orders' );
function custom_columns_content_in_admin_orders( $column ) {
global $post, $the_order;
if ( 'order_shipping' === $column ) {
echo $the_order->get_shipping_method();
}
if ( 'order_payment' === $column ) {
echo $the_order->get_payment_method_title();
}
}
代码位于活动子主题(或活动主题)的functions.php 文件中。经过测试并有效。
- 1 回答
- 0 关注
- 169 浏览
添加回答
举报