如何编辑woocommerce管理订单页面? [英] How to edit woocommerce admin order page?
问题描述
我使用的是最新的 Woocommerce 版本 2.4.12.我想对 woocommerce --> 订单下管理仪表板中的订单页面进行一些更改.
I am using Woocommerce version 2.4.12, the latest one. I want to make some changes to orders page that is in the admin dashboard under woocommerce --> orders.
它在 plugins->woocommerce 文件夹中的文件在哪里?我在我的主题中创建了一个 woocommerce 文件夹来覆盖模板文件.我想将客户的电话号码添加到 ship_to 列.客户希望在订单页面上显示客户的电话号码.有什么方法可以使用functions.php 添加钩子并进行更改吗?
Where is it's file in plugins->woocommerce folder? I have made a woocommerce folder in my theme to override template files. I want to add phone number of the customer to the ship_to column. Client wants Phone number of customer visible on the orders page. Any way to use functions.php to add a hook and make changes?
推荐答案
试试这个到你的 functions.php
add_filter( 'manage_edit-shop_order_columns', 'shop_order_columns' );
function shop_order_columns( $columns ){
$new_columns = (is_array($columns)) ? $columns : array();
$new_columns['phone'] = 'Phone';
return $new_columns;
}
add_action( 'manage_shop_order_posts_custom_column', 'shop_order_posts_custom_column' );
function shop_order_posts_custom_column( $column ){
global $post, $the_order;
if ( empty( $the_order ) || $the_order->get_id() != $post->ID ) {
$the_order = wc_get_order( $post->ID );
}
$billing_address = $the_order->get_address();
if ( $column == 'phone' ) {
echo ( isset( $billing_address['phone'] ) ? $billing_address['phone'] : '');
}
}
位置问题??..
为第一个函数试试这个
function shop_order_columns($columns){
$columns = (is_array($columns)) ? $columns : array();
$phone = array( 'phone' => 'Phone' );
$position = 5;
$new_columns = array_slice( $columns, 0, $position, true ) + $phone;
return array_merge( $new_columns, $columns );
}
针对 WooCommerce 3 进行了更新.
这篇关于如何编辑woocommerce管理订单页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!