WooCommerce-POS icon indicating copy to clipboard operation
WooCommerce-POS copied to clipboard

Question: Searching customers including meta data

Open peterlaws opened this issue 8 years ago • 2 comments

Is there a custom hack to be able to search users including their wp meta_data table fields, eg. billing_company? As in, searching the customers on the front-end cart.

I've been at this nearly all day for a friend and now I'm banging my head on the desk.

This file is the ajax call plugins/woocommerce-pos/includes/api/class-wc-pos-customers.php I assume does the db searching but all I see it just manipulating the $wp_user_query->query_where.

Normally the WP_User_Query just needs the : 'meta_query' => array ( array ( 'relation' => 'LIKE', array( 'key' => 'billing_company', 'value' => $term ) ) )

TIA

peterlaws avatar Jan 09 '17 18:01 peterlaws

Hi,

as far as I can tell (from the tests I have made) you should be able to search by:

  • email
  • username
  • first name
  • last name
  • billing phone number
  • billing company

you can see how I tested here: http://take.ms/eNsJk

2 customers with company: The Flower Shop 1 customer with phone number containing: 666 1 customer with phone number containing: 999

it's been tested with 0.5 beta

I've seen issues with the local db not syncing properly with the backend so you might want to clear the local db (POS Menu>Support>Local storage box>Clear customers)

let me know if this helps

thomasmery avatar Jan 10 '17 10:01 thomasmery

Thomas is correct, in version 0.5 the following fields are searched. Note that customers are stored locally, so search actually happens in javascript, adding custom PHP won't change how the POS operates.

Version 0.4 only searches the following fields by default: email, username, first_name and last_name.

Also please note that search is something that is still being developed on the WC REST API side. Both WooCommerce and WooCommerce POS are working towards a future where every attribute can be searched and default settings can be set.

kilbot avatar Jan 10 '17 14:01 kilbot