if( isset( $_GET['wpo_find_customer'] ) ) { add_filter( "woocommerce_json_search_found_customers", function($customers){ foreach($customers as $key=>$data) { if($data['type'] == 'order' ) { $order = new WC_Order($data['id']); $title = sprintf( esc_html__( '%1$s (#%2$s – %3$s)', 'phone-orders-for-woocommerce' ), implode( ' ', array( current( array_filter( array( $order->get_billing_first_name(), $order->get_shipping_first_name(), ) ) ), current( array_filter( array( $order->get_billing_last_name(), $order->get_shipping_last_name(), ) ) ), ) ), get_user_meta($order->get_customer_id(), "SavingsID", true), $order->get_billing_address_1() ); } elseif($data['type'] == 'customer' ) { $customer = new WC_Customer($data['id']); $title = sprintf( esc_html__( '%1$s (#%2$s – %3$s)', 'phone-orders-for-woocommerce' ), implode( ' ', array( current( array_filter( array( $customer->get_billing_first_name(), $customer->get_shipping_first_name(), ) ) ), current( array_filter( array( $customer->get_billing_last_name(), $customer->get_shipping_last_name(), ) ) ), ) ), get_user_meta($data['id'], "SavingsID", true), $customer->get_billing_address_1() ); } $customers[$key]['title'] = $title; } return $customers; },100); }
Customize autocomplete results ( + user meta field SavingsID ) Print
Created by: Alex Prokaev
Modified on: Mon, 7 Oct, 2019 at 10:02 AM
Did you find it helpful? Yes No
Send feedbackSorry we couldn't be helpful. Help us improve this article with your feedback.