Filter store listing
-
Hi,
I try to filter the seller_listing_search function in ajax.php. I need to add “city” and “zip” from “dokan_profile_meta” in usermeta table.
I use this:
public function seller_listing_search() { if ( ! isset( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'dokan-seller-listing-search' ) ) { wp_send_json_error( __( 'Error: Nonce verification failed', 'dokan' ) ); } $paged = 1; $limit = 10; $offset = ( $paged - 1 ) * $limit; $seller_args = array( 'number' => $limit, 'offset' => $offset ); $search_term = isset( $_REQUEST['search_term'] ) ? sanitize_text_field( $_REQUEST['search_term'] ) : ''; $pagination_base = isset( $_REQUEST['pagination_base'] ) ? sanitize_text_field( $_REQUEST['pagination_base'] ) : ''; if ( '' != $search_term ) { $seller_args['search'] = "*{$search_term}*"; $seller_args['search_columns'] = array( 'display_name' ); $val = rtrim( ltrim( maybe_serialize( array("city" => $search_term) ), 'a:6:{' ), '}' ); $val2 = rtrim( ltrim( maybe_serialize( array("zip" => $search_term) ), 'a:6:{' ), '}' ); $seller_args['meta_query'] = array( 'relation' => 'OR', array( 'key' => 'dokan_enable_selling', 'value' => 'yes', 'compare' => '=' ), array( 'key' => 'dokan_profile_settings', 'value' => $val, 'compare' => 'LIKE' ), array( 'key' => 'dokan_profile_settings', 'value' => $val2, 'compare' => 'LIKE' ) ); } $sellers = dokan_get_sellers( $seller_args ); $template_args = apply_filters( 'dokan_store_list_args', array( 'sellers' => $sellers, 'limit' => $limit, 'paged' => $paged, 'image_size' => 'medium', 'search' => 'yes', 'pagination_base' => $pagination_base, 'search_query' => $search_term, ) ); ob_start(); dokan_get_template_part( 'store-lists-loop', false, $template_args ); $content = ob_get_clean(); wp_send_json_success( $content ); }
But not work… How can I add city and zip in searching function ?
Thanks
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘Filter store listing’ is closed to new replies.