Created
April 23, 2018 05:30
-
-
Save Steeru/a1b03238163a9fac9fd2bb5544d3e6ce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Product search template. | |
* | |
* @package eCommerce_Market_Pro | |
*/ | |
?> | |
<?php $args = array( | |
'number' => '', | |
'orderby' => 'name', | |
'order' => 'ASC', | |
'hide_empty' => true | |
); | |
$product_categories = get_terms( 'product_cat', $args ); | |
$categories_show = '<option value="">' . __( 'All Categories', 'ecommerce-market-pro' ) . '</option>'; | |
$check = ''; | |
if ( is_search() ) { | |
if ( isset( $_GET['term'] ) && $_GET['term'] != '' ) { | |
$check = sanitize_text_field(sanitize_text_field($_GET['term'])); | |
} | |
} | |
$checked = ''; | |
foreach ( $product_categories as $category ) { | |
if ( isset( $category->slug ) ) { | |
if ( trim( $category->slug ) == trim( $check ) ) { | |
$checked = 'selected="selected"'; | |
} | |
$categories_show .= '<option ' . $checked . ' value="' . esc_attr( $category->slug ) . '">' . esc_html( $category->name ) . '</option>'; | |
$checked = ''; | |
} | |
} | |
$form = '<form role="search" class="woocommerce-product-search" method="get" id="searchform" action="' . esc_url( home_url( '/' ) ) . '"> | |
<div class="advance-search-form"> | |
<input type="search" value="' . get_search_query() . '" name="s" id="s" class="search-input typeahead" placeholder="' . esc_attr__( 'Search for products', 'ecommerce-market-pro' ) . '" /> | |
<input type="hidden" name="post_type" value="product" /> | |
<input type="hidden" name="taxonomy" value="product_cat" /> | |
<input type="submit" value="" /> | |
</div> | |
</form>'; | |
echo $form; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment