你可以使用一些CSS来隐藏客户的IP地址,比如:
add_action( 'admin_head', 'admin_edit_order_css' );
function admin_edit_order_css() {
global $pagenow, $typenow;
if ( ( $pagenow === 'post.php' && $typenow === 'shop_order' && isset($_GET['post']) )
|| ( $pagenow === 'admin.php' && isset($_GET['page']) && $_GET['page'] === 'wc-orders'
&& isset($_GET['action']) && $_GET['action'] === 'edit' && isset($_GET['id']) ) ) : ?>
<style> .woocommerce-Order-customerIP {display:none;} </style>
<?php endif;
}
但它只会隐藏IP地址本身,而不会隐藏“客户IP:”子字符串。
因此,您可以使用Javascript删除IP并隐藏“客户IP:”子字符串,如:
add_action( 'admin_footer', 'admin_edit_order_script' );
function admin_edit_order_script() {
global $pagenow, $typenow;
if ( ( $pagenow === 'post.php' && $typenow === 'shop_order' && isset($_GET['post']) )
|| ( $pagenow === 'admin.php' && isset($_GET['page']) && $_GET['page'] === 'wc-orders'
&& isset($_GET['action']) && $_GET['action'] === 'edit' && isset($_GET['id']) ) ) : ?>
<script>
jQuery('.woocommerce-Order-customerIP').remove();
const orderNumberMeta = jQuery('.woocommerce-order-data__meta.order_number'),
orderNumberMetaHTML = orderNumberMeta.html();
orderNumberMeta.html(orderNumberMetaHTML.replace('Customer IP:', ''));
</script>
<?php endif;
}
代码位于子主题的functions.php文件中(或插件中)。经过测试,可以在有或没有的情况下工作
HPOS
启用。
你会得到这样的结果: