kilbot / WooCommerce-POS

:bangbang: All development now at https://github.com/wcpos.
http://wcpos.com
GNU General Public License v3.0
353 stars 125 forks source link

Question: Searching customers including meta data #152

Open peterlaws opened 7 years ago

peterlaws commented 7 years ago

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

thomasmery commented 7 years ago

Hi,

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

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

kilbot commented 7 years ago

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.