Woocommerce自定义搜索

时间:2014-05-22 05:59:13

标签: wordpress woocommerce

我想在woo-commerce网站上创建一个自定义搜索类别,最低价格和最高价格。我试过下面的代码

<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>

类别搜索效果很好,但搜索中未包含最低和最高价格值

请帮帮我

0 个答案:

没有答案