This topic has 4 replies, 2 voices, and was last updated 9 years, 7 months ago ago by Eva Kemp
Can the search form be set somehow to include the SKU number as well as the product name and description on the WooPress theme?
Hello,
You can edit the file wp-content/themes/woopress/woosearchform.php (line 15) and delete the code
<input type="hidden" name="post_type" value="product" />
. You’ll have default search form.
Regards,
Eva Kemp.
I deleted that line as instructed. I have attached the remaining code below. When I search for a product by sku what I get seems to be just posts that have that sku number in vs. the actual product with that sku number.
Here is the remaining code:
<?php
/**
* The template for displaying search forms
*
*/
?>
<?php if(class_exists(‘Woocommerce’)) : ?>
<form action=”<?php echo esc_url( home_url( ‘/’ ) ); ?>” id=”searchform” class=”hide-input” method=”get”>
<div class=”form-horizontal modal-form”>
<div class=”form-group has-border”>
<div class=”col-xs-10″>
<input type=”text” value=”<?php if(get_search_query() == ”){ esc_attr_e(‘Search for products’, ETHEME_DOMAIN);} else { the_search_query(); } ?>” class=”form-control” onblur=”if(this.value==”)this.value='<?php _e(‘Search for products’, ETHEME_DOMAIN); ?>'” onfocus=”if(this.value=='<?php _e(‘Search for products’, ETHEME_DOMAIN); ?>’)this.value=”” name=”s” id=”s” />
</div>
</div>
<div class=”form-group form-button”>
<button type=”submit” class=”btn medium-btn btn-black”><?php esc_attr_e( ‘Search’, ETHEME_DOMAIN ); ?></button>
</div>
</div>
</form>
<?php else: ?>
<?php get_template_part(‘searchform’); ?>
<?php endif ?>
Hello,
You can try to use this plugin:
https://wordpress.org/plugins/search-by-sku-for-woocommerce/
Regards,
Eva Kemp.
You must be logged in to reply to this topic.Log in/Sign up