[英]Search WooCommerce orders admin for custom fields
Probably a very simple question but it leaves me clueless.. 可能是一个非常简单的问题,但这使我毫无头绪。
On the web if found the following code for searching a custom field on the order page. 在网络上,如果找到以下代码以搜索订单页面上的自定义字段。 What If I wanted to scope another field?
如果我想扩展另一个领域怎么办?
add_filter( 'woocommerce_shop_order_search_fields', 'woocommerce_shop_order_search_order_total' );
function woocommerce_shop_order_search_order_total( $search_fields ) {
$search_fields[] = 'woochimp_field';
return $search_fields;
}
Thanks 谢谢
$search_fields[]
Is an Array as it turns out. $search_fields[]
实际上是一个数组。 Every time you use $search_fields[] = 'woochimp_field';
每次使用
$search_fields[] = 'woochimp_field';
you add to the array and makes you able to search more custom fields. 您将添加到数组中,并使您能够搜索更多自定义字段。
add_filter( 'woocommerce_shop_order_search_fields', 'woocommerce_shop_order_search_order_total' );
function woocommerce_shop_order_search_order_total( $search_fields ) {
$search_fields[] = 'woochimp_field';
$search_fields[] = 'woochimp_field_2'; //example
return $search_fields;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.