public function json_search_customers() { global $wpdb; check_ajax_referer('search-customers', 'security'); header('Content-Type: application/json; charset=utf-8'); $term = urldecode(stripslashes(strip_tags($_GET['term']))); if (empty($term)) { die; } $users = get_customer_by_term($term); $found_customers = array(); if ($users) { foreach ($users as $user) { $found_customers[$user->email] = $user->first_name . ' ' . $user->last_name . ' (' . (!empty($user->user_id) ? '#' . $user->user_id : __("Guest", 'wc_customer_relationship_manager')) . ' – ' . sanitize_email($user->email) . ')'; } } echo json_encode($found_customers); die; }
public function woocommerce_crm_customer_name_filter() { global $wpdb; ?> <select id="dropdown_customers" name="_customer_user"> <option value=""><?php _e('Show all customers', 'wc_customer_relationship_manager'); ?> </option> <?php if (!empty($_REQUEST['_customer_user'])) { $user = $_REQUEST['_customer_user']; $user_results = get_customer_by_term($user); foreach ($user_results as $user) { echo '<option value="' . $user->email . '" '; selected(1, 1); echo '>' . $user->first_name . ' ' . $user->last_name . ' (' . (!empty($user->user_id) ? '#' . $user->user_id : __("Guest", 'wc_customer_relationship_manager')) . ' – ' . sanitize_email($user->email) . ')' . '</option>'; } } ?> </select> <?php }