Woocommerce custom search

I want to create a custom search in woo-commerce website with category, minimum and maximum price. I tried below code

<form role="search" method="get" id="searchform" action="<?php echo esc_url( home_url( '/'  ) ); ?>" class="top-search-box">
                    <input type="text" value="<?php echo get_search_query(); ?>" name="s" id="s" class="top-search-input" placeholder="<?php _e( 'Search entire collection...', 'woocommerce' ); ?>">
                    <select name="product_cat">
                        <option value="">Select Category</option>
                         <?php  $args = array( 'taxonomy' => 'product_cat','hide_empty'=>0 );
                            $terms = get_terms('product_cat', $args); 
                            if (count($terms) > 0) { 
                            //print_r($terms);
                            foreach ($terms as $term) { ?>
                                <option <?php if($term->slug == $_REQUEST['product_cat']){?> selected <?php } ?> value="<?php echo $term->slug; ?>"><?php echo $term->name; ?></option>
                          <?php } } ?>  

                    </select>
                    <input type="text" name="min_price" class="top-search-input"  />
                    <input type="text" name="max_price" class="top-search-input" />
                    <input type="hidden" name="post_type" value="product" />
                    <button class="top-search-btn" id="searchsubmit"><i class="fa fa-search"></i></button>
                </form>

Category search works perfectly, but min and max price values not included in search

Read More

Please help me

Related posts

Leave a Reply