Search to include SKU number - by jjersild

This topic has 4 replies, 2 voices, and was last updated 9 years, 6 months ago ago by Eva Kemp

  • Avatar: jjersild
    jjersild
    Participant
    May 14, 2015 at 15:47

    Can the search form be set somehow to include the SKU number as well as the product name and description on the WooPress theme?

    3 Answers
    Avatar: Eva
    Eva Kemp
    Support staff
    May 14, 2015 at 17:19

    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.

    Avatar: jjersild
    jjersild
    Participant
    May 15, 2015 at 20:04

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

    Avatar: Eva
    Eva Kemp
    Support staff
    May 16, 2015 at 11:19

    Hello,

    You can try to use this plugin:
    https://wordpress.org/plugins/search-by-sku-for-woocommerce/

    Regards,
    Eva Kemp.

  • Viewing 4 results - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.Log in/Sign up

8theme customization service
We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.