Quantcast
Viewing all articles
Browse latest Browse all 10

Tweaking the WooCommerce Order Admin: Searching For Custom Fields

Image may be NSFW.
Clik here to view.

The WooCommerce Order Admin allows you to search for ordres by the following fields:

  • order key
  • billing first name
  • billing last name
  • billing company
  • billing address 1
  • billing address 2
  • billing city
  • billing postcode
  • billing country
  • billing state
  • billing email
  • billing phone
  • order items

But what if you want to search by another order field? Perhaps the order total? Well it’s as easy as adding something like the following to your themes functions.php:

add_filter( 'woocommerce_shop_order_search_fields', 'woocommerce_shop_order_search_order_total' );

function woocommerce_shop_order_search_order_total( $search_fields ) {
  $search_fields[] = '_order_total';
  return $search_fields;
}

With that simple snippet active you can now search by order total. Note that with the numerical fields like total, you’d need to search with no thousands separator, and a period for the decimal place holder, ie: 1000.50 regardless of how you have configured WooCommerce to display totals on the frontend. That’s due to the way the numbers are stored within WooCommerce. Using this technique you can even search by custom post meta that you may be adding to the order records.

The post Tweaking the WooCommerce Order Admin: Searching For Custom Fields appeared first on Fox Run Software.


Viewing all articles
Browse latest Browse all 10

Trending Articles