将电话号码添加到 wooCommerce 订单列表中的搜索功能



我正在使用WooCommerce,我需要一些帮助。如何将搜索功能扩展到管理员WooCommerce订单列表中的客户电话号码?

这实际上是我的代码。

function woocommerce_shop_order_search_custom_keys( $search_fields ) {
$search_fields[] = '_order_number';
$search_fields[] = '_billing_phone';
$search_fields[] = '_billing_id';
return $search_fields;
} 

但不起作用


编辑:我也尝试将其添加到我的代码中,但没有任何成功:

add_filter( 'woocommerce_shop_order_search_fields', 'woocommerce_shop_order_search_custom_keys' ); 

在筛选器挂钩woocommerce_shop_order_search_fields自定义函数中的订单列表搜索字段中获取计费电话的正确方法是:

add_filter( 'woocommerce_shop_order_search_fields', 'billing_phone_search_fields', 10, 1 );
function billing_phone_search_fields( $meta_keys ){
$meta_keys[] = '_billing_phone';
return $meta_keys;
}

代码进入函数.php活动子主题(或主题(的文件或任何插件文件中。

此代码在WooCommerce 3+上进行了测试并有效。

最新更新