Please note: This forum is now closed. All the support related enquiries should be reported on wordpress support forum for jigoshop plugin – thanks, Jigoshop Team

Product Search

joshrodgers's Avatar

joshrodgers

26 Apr, 2012 04:29 PM

Hello there,

I am trying to create a product search feature and ran into a little roadblock...I cannot return Jigoshop search results :(

So, this is where I'm at...

I copied the search form from the product_search widget and came up with the following code:

<form method="get" id="searchform" action="<?php echo home_url(); ?>">
    <input type="text" value="Search..." name="s" id="s" />
    <input type="hidden" name="post_type" value="product" />
    <input type="submit" id="searchsubmit" value="Search" />
</form>

Then, I enhanced the code a little by adding some default text that disappears when the user clicks on the input, as well as, a couple of dropdowns that allow the user to select multiple categories:

<form method="get" id="searchform" action="<?php echo home_url(); ?>">
    <input type="text" onclick="this.value='';" onfocus="this.select()" onblur="this.value=!this.value?'Search...':this.value;" value="Search..." name="s" id="s" />
    <input type="hidden" name="post_type" value="product" />
    <?php wp_dropdown_categories('taxonomy=product_cat&id=make&child_of=15&show_option_all=Select Make...'); ?>
    <?php wp_dropdown_categories('taxonomy=product_cat&id=model&child_of=21&show_option_all=Select Model...'); ?>
    <input type="submit" id="searchsubmit" value="Search" />
</form>

Before I added the code above, I tested it with normal WordPress posts and it worked fine, so there is nothing wrong with this code.

After that, I added a search page to return my search results, the code looks like:

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <?php the_title(); ?>
    <?php the_content(); ?>
<?php endwhile; else: ?>
    <?php _e('No content!'); ?>
<?php endif; ?>

This code is working fine with normal WordPress posts, but for some reason it doesn't return the Jigoshop search results.

So, I created an example site at: joshrodgers.com. If you search for title and choose Volvo as the make and XC90 as the model you can see this issue. The results page says No Content!

I thought I was going crazy, so I added a small piece of code to echo the search term and tell me how many results were found. This is working. If you run my suggested search from above you'll notice this code says 5 results. I know its working properly because if you search for the word two, instead of title, it shows 1 result.

So, what's wrong with my search result code? I am so close...I just can't seem to figure out what I'm missing.

Any Ideas?

Thanks,
Josh

Showing the most recent page of comments. View the first page

  1. 32 Posted by arcadence on 03 Jul, 2012 09:29 PM

    arcadence's Avatar

    Does the Jigoshop widget allow you to create an advanced search or even a step-by-step conditional search (i.e. You select Make which gives you certain options to the Model for that specific Make)? <--- Is there a specific terminology for this type of search?

    @Josh very nice layout.

  2. Support Staff 33 Posted by chriscct7 on 03 Jul, 2012 09:33 PM

    chriscct7's Avatar

    Out of box no, and no. I have seen this custom coded using taxonomy and custom fields however.

    -Chris

  3. 34 Posted by arcadence on 03 Jul, 2012 09:45 PM

    arcadence's Avatar

    I'm looking into custom taxonomy plugins now. I'm hoping to be able to get something that I can use in conjunction with jigoshop, as I'm already familiar with the way jigo works (setting up my store), but like Josh, I'm looking to utilize a Make/Model/Trim of cars so that people can see a list of specialized parts.

Comments are closed, but you can start a new discussion.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac