Skip to content

Commit

Permalink
fix: store search with meta query
Browse files Browse the repository at this point in the history
  • Loading branch information
kapilpaul committed Dec 2, 2020
1 parent 5c975e1 commit 2095486
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions includes/REST/StoreController.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,23 @@ public function get_stores( $request ) {
$args = apply_filters( 'dokan_rest_get_stores_args', $args, $request );

$stores = dokan()->vendor->get_vendors( $args );

// if no stores found in then we are searching again with meta value. here need to remove search and search_columns, because with this args meta_query is not working
if ( ! count( $stores ) ) {
unset( $args['search'] );
unset( $args['search_columns'] );

$args['meta_query'] = [
[
'key' => 'dokan_store_name',
'value' => sanitize_text_field( $params['search'] ),
'compare' => 'LIKE',
],
];

$stores = dokan()->vendor->get_vendors( $args );
}

$data_objects = [];

foreach ( $stores as $store ) {
Expand Down

0 comments on commit 2095486

Please sign in to comment.