I have done this with simple text field with submit button.bellow is the code.
function wc_vendors_location78( $atts ) {
$html = '';
extract( shortcode_atts( array(
'orderby' => 'display_name',
'order' => 'ASC',
'per_page' => '1',
'columns' => '4',
'show_products' => 'yes',
'pv_shop_name' => '',
'meta_compare' => 'LIKE',
//'org' => '',
), $atts ) );
// Hook into the user query to modify the query to return users that have at least one product
if ($show_products == 'yes') //remove_action( 'pre_user_query', array( $this, 'vendors_with_products') );
//add_action( 'pre_user_query', array( $this, 'vendors_with_products1') );
add_action( 'pre_user_query','vendors_with_products' );
// Get all vendors
$vendor_total_args = array (
'role' => 'vendor',
'meta_key' => 'pv_shop_slug',
'meta_value' => '',
'meta_key' => 'pv_shop_name',
'meta_value' => $_POST[ 'serchbyvendornamessss' ],
'meta_compare' => 'LIKE'
//'orderby' => $orderby,
//'order' => $order,
);
if ($show_products == 'yes') $vendor_total_args['query_id'] = 'vendors_with_products';
$vendor_query = New WP_User_Query( $vendor_total_args );
$all_vendors =$vendor_query->get_results();
ob_start();
// Loop through all vendors and output a simple link to their vendor pages
foreach ($all_vendors as $vendor) {
wc_get_template( 'vendor-list.php', array(
'shop_link' => WCV_Vendors::get_vendor_shop_page($vendor->ID),
'shop_name' => $vendor->pv_shop_name,
'vendor_id' => $vendor->ID,
'shop_description' => $vendor->pv_shop_description,
), 'wc-vendors/front/', wcv_plugin_dir . 'templates/front/' );
} // End foreach
// $html .= '<ul class="wcv_vendorslist">' . ob_get_clean() . '</ul>';
$html .= '<ul class="wcv_vendorslist">' . ob_get_clean() . '</ul>';
if ($total_vendors > $total_vendors_paged) {
$html .= '<div class="wcv_pagination">';
$current_page = max( 1, get_query_var('paged') );
$html .= paginate_links( array(
'base' => get_pagenum_link(1) . '%_%',
'format' => 'page/%#%/',
'current' => $current_page,
'total' => $total_pages,
'prev_next' => false,
'type' => 'list',
));
$html .= '</div>';
}
return $html;
//return $html;
}
//start speciality
if ( !empty($_POST[ 'serchbyvendornamessss' ] ) ) {
add_shortcode('wc_vendors_location', 'wc_vendors_location78');
}