• Resolved ilanb

    (@ilanb)


    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)
  • Plugin Author weDevs

    (@wedevs)

    Hello @ilanb, You have already submitted a ticket to our paid support forum. As you are a paid user for that reason, we will request you to keep following the ticket which you have sent. Also, we are now on the weekend. On Sunday our developer will provide good hints to you.If you can then share this full code on the ticket which you have created ??

    Thread Starter ilanb

    (@ilanb)

    Hi,

    I’v shared full code with support but no response from it!

    Thx

    Hi,

    The address values of Dokan Vendors are saved under ‘dokan_profile_settings’ user meta with a key of [‘address’]. So, Meta query on that is not possible .

    What you can do is override the /dokan-plugin/templates/store-lists-loop.php template and within the for loop do a check if $store_info['address']['city '] matches your provided city and only then print the listing.

    Thread Starter ilanb

    (@ilanb)

    Just reply here my email:

    Ok I can understand for policy… But isn’t logic that this simple search function is not include by default… a search by address and zip for a store is basic, and user never search by name first…

    But I suppose you encourage work for third party developper ?

    I’ts my two cent’s analyse.

    Anyway thanks for provide part of request.

    Hi @ilanb,

    We understand that this feature is important for seller search. We are gradually improving our features according to our client responses. Thanks for suggesting us this improvement. We will include it in our future update.

    Thanks ??

    Thread Starter ilanb

    (@ilanb)

    Hi Sabbir,

    Thanks for understanding user point of view ??

    Ilan

    Thread Starter ilanb

    (@ilanb)

    Hi Kas5986,

    That sound good ??
    Where I can download your plugin ? no link on your demo site

    Thanks

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Filter store listing’ is closed to new replies.