Support » Plugin: FoxyShop » Adding Variation Descriptions to Search

  • Resolved madla


    I have some text in the variations for some items (name, description field) that I would like to be included in the search.

    My testing indicates that it’s not included at all. How would I go about doing that?


Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author sparkweb


    This isn’t handled natively by WP at all, but there’s some good tips here:

    You can edit the search query in the template file: foxyshop-search.php

    I’m stuck on that one. Based that post, I should be able to add a filter to add more to the search. But I don’t know that the right fields are. I’d like to search through category names and descriptions as well as production variation names and descriptions.

    From the post

    function custom_search_where($where) {
        // put the custom fields into an array
        $customs = array('custom_field1', 'custom_field2', 'custom_field3');
        foreach($customs as $custom) {
    	$query .= " OR (";
    	$query .= "(m.meta_key = '$custom')";
    	$query .= " AND (m.meta_value  LIKE '{$n}{$term}{$n}')";
            $query .= ")";
        $where = " AND ({$query}) AND ($wpdb->posts.post_status = 'publish') ";
    add_filter('posts_where', 'custom_search_where');

    Any help would be appreciated.

    Plugin Author sparkweb


    Theoretically this should work, but as I did some test code, I found that it was doing AND instead of OR with traditional meta queries. I haven’t been able to figure out how to change that.

    Additionally, all the variation data is stored in separate fields so it would be a large query to search through them all. I’m afraid I don’t have a very good solution at this point.


    What about the category information? Can I add that to the search?

    Would you mind sharing the test code you mentioned above? If I can see how your accessing the fields perhaps I can figure something out.

    Plugin Author sparkweb


    well, I was doing foxyshop-search.php and adding this to the $args:

    $args['meta_query'] = array(
    		'key' => '_code',
    		'value' => $search,
    		'compare' => 'LIKE'

    And that was working, but only if I took out the ‘s’=>$search bit from the $args. If you look at the query with the blackbox plugin you can see that it’s using AND for the meta_query.

    I wonder if it would be better to just do a completely custom query with $wpdb….

    Plugin Author sparkweb


    I’d also mention on this one that I have just finished doing some serious upgrades to variation setup for version 3.0. All the variations are now stored in one custom field so it is much more efficient and easier to search variations if you wanted to search that out. If you do want to try this out, send a support request from and I’ll email you the 3.0 beta.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Adding Variation Descriptions to Search’ is closed to new replies.