WC_REST_Products_Controller::add_search_criteria_to_wp_query_where()publicWC 1.0

Add a where clause for matching the SKU field.

Method of the class: WC_REST_Products_Controller{}

No Hooks.

Return

String.

Usage

$WC_REST_Products_Controller = new WC_REST_Products_Controller();
$WC_REST_Products_Controller->add_search_criteria_to_wp_query_where( $where );
$where(string) (required)
Where clause used to search posts.

WC_REST_Products_Controller::add_search_criteria_to_wp_query_where() code WC 9.5.1

public function add_search_criteria_to_wp_query_where( $where ) {
	global $wpdb;
	if ( ! empty( $this->search_sku_in_product_lookup_table ) ) {
		$like_search = '%' . $wpdb->esc_like( $this->search_sku_in_product_lookup_table ) . '%';
		$where      .= ' AND ' . $wpdb->prepare( '(wc_product_meta_lookup.sku LIKE %s)', $like_search );
	}
	return $where;
}