要使用的正确滤清器挂钩为manage_edit-shop_order_columns
.
1) To remove shipping_address
列:
add_filter( \'manage_edit-shop_order_columns\', \'remove_specific_orders_column\' );
function remove_specific_orders_column( $columns ){
unset( $columns[\'shipping_address\'] );
return $new_columns;
}
代码进入函数。活动子主题(或活动主题)的php文件。已测试并正常工作。
<小时>2) Replace the content 属于shipping_address
列:
下面的示例将替换管理订单列表中的“发货地址”列内容:
add_filter( \'manage_edit-shop_order_columns\', \'customizing_orders_columns\' );
function customizing_orders_columns( $columns ){
$new_columns = [];
foreach ( $columns as $key => $column ) {
if( $key === \'shipping_address\' ) {
$new_columns[\'shipping_addr_repl\'] = $column;
} else {
$new_columns[$key] = $column;
}
}
return $new_columns;
}
<小时>
add_action( \'manage_shop_order_posts_custom_column\', \'set_custom_shipping_address_content_replacement\' );
function set_custom_shipping_address_content_replacement( $column ) {
global $the_order, $post;
if ( \'shipping_addr_repl\' === $column ) {
// YOUR REPLACEMENT CODE (Fake example below)
echo $the_order->get_shipping_city();
}
}
代码进入函数。活动子主题(或活动主题)的php文件。已测试并正常工作。
此列最初显示的内容代码为:
$address = $the_order->get_formatted_shipping_address();
if ( $address ) {
echo \'<a target="_blank" href="\' . esc_url( $the_order->get_shipping_address_map_url() ) . \'">\' . esc_html( preg_replace( \'#<br\\s*/?>#i\', \', \', $address ) ) . \'</a>\';
if ( $the_order->get_shipping_method() ) {
/* translators: %s: shipping method */
echo \'<span class="description">\' . sprintf( __( \'via %s\', \'woocommerce\' ), esc_html( $the_order->get_shipping_method() ) ) . \'</span>\'; // WPCS: XSS ok.
}
} else {
echo \'–\';
}