Digital experiences for all disciplines
New Landing › How can we help? › Themeforest Theme Support › Dante › Super Search/Personal Shopper: how to limit terms to search for within a list
New Landing › How can we help? › Themeforest Theme Support › Dante › Super Search/Personal Shopper: how to limit terms to search for within a list
- This topic has 11 replies, 4 voices, and was last updated 10 years by Mohammad – SUPPORT.
-
Posted in: Dante
-
September 13, 2014 at 1:10 pm #110337
Hi!
I hope I wrote the title correctly.
I purchased your wonderful theme ONLY because it has Personal Shopper feature… Ok, honestly, because it’s awesome in its whole bunch of features.
Therefore, I’d like to know if it’s possible to limit search terms of a specific list.
e.g.: within “Color” attribute list, I listed sooo many colors, both with or without numbers (violet or 001-violet) that, if I set that list to be in Super Search, one can’t search a product at all or with a bad experience (for instance, one can’t scroll the entire list – scrolling down make the list disappear). I’d like to provide customers the ability to search for colors within “Color” attribute list, but only for a few of them, not the whole list. Do you think it’s possible?
Thanks to you all, regards.Attachments:
You must be logged in to view attached files.September 15, 2014 at 12:37 am #110468Hi,
I assume that you are good at code editing, to limit its number go to this file
\wp-content\themes\neighborhood\includes\swift-framework\sf-content-display\sf-header.php at line #111 you saw some lines like this
$term_args = array( 'parent' => 0, );
edit that to
$term_args = array( 'parent' => 0, 'number' => 5, );
to limit its out to 5.. Though it will limit all the other things in the search too, so if you want specific link to limit it, use the $index option like
if ( $index == '1' ){ $term_args = array( 'parent' => 0, 'number' => 5, ); } else{ $term_args = array( 'parent' => 0, ); }
where 1 is the first link in the search, if that is 2link change it to 2.
Be careful with code edits, before making changes to the file, take a backup of that file, and start editing if something goes wrong back up it back.. For more term_args customization in query refer this http://codex.wordpress.org/Function_Reference/get_terms ( there you can include certain terms along and exclude some )
Hope this helps.
Let us know,
Thanks,
laranz.September 15, 2014 at 6:58 am #110509Hi laranz!
Thanks for your reply.
I’d like to try your suggested solution asap, but you gave me Neighborhood’s links instead of Dante’s ones. I think folder paths are a bit different from one to another.
I think the right link is to sf-supersearch.php, line 130. Please attached screenshot and let me know.
Thanks!***EDIT***
Yeah, that’s the file and… IT WORKS!
Many many thanks!Attachments:
You must be logged in to view attached files.September 15, 2014 at 7:23 am #110526Hi
Looks good to me, glad it works ๐
Thanks Laranz
– Kyle
September 15, 2014 at 7:54 am #110542Great guys!
Last question: in order to have this modification forever and save it from further major updates, what should I do? I tried to replicate file path within child theme’s folder, but unsuccessfully.September 15, 2014 at 8:07 am #110546You will need to copy the whole function into your child themes functions.php file:
if (!function_exists('sf_super_search_dropdown')) { function sf_super_search_dropdown($index, $option, $text) { global $product; $option_id = $sf_ss_dropdown = $default_term_id = ""; $option_id = $option; if ($option != "product_cat" && $option != "price") { $option = 'pa_' . $option; } $default_term = get_term_by('name', $text, $option); if ($default_term) { if ($option == "product_cat") { $default_term_id = $default_term->slug; } else { $default_term_id = $default_term->term_id; } } $term_args = array( 'parent' => 0, ); if ($option == "price") { global $wpdb, $woocommerce; $max = ceil( $wpdb->get_var( $wpdb->prepare(' SELECT max(meta_value + 0) FROM %1$s LEFT JOIN %2$s ON %1$s.ID = %2$s.post_id WHERE meta_key = \'%3$s\' ', $wpdb->posts, $wpdb->postmeta, '_price' ) ) ); $sf_ss_dropdown .= '<input type="text" pattern="[0-9]*" id="ss-price-min" name="min_price" value="0" />'; $sf_ss_dropdown .= '<span>&</span>'; $sf_ss_dropdown .= '<input type="text" pattern="[0-9]*" id="ss-price-max" name="max_price" value="'.$max.'" />'; } else { $terms = get_terms($option, $term_args); $sf_ss_dropdown .= '<div id="'.$option_id.'" class="ss-dropdown" tabindex="'.$index.'" data-attr_value="'.$default_term_id.'">'; $sf_ss_dropdown .= '<span>'.$text.'</span>'; $sf_ss_dropdown .= '<ul>'; $sf_ss_dropdown .= '<li>'; $sf_ss_dropdown .= '<a class="ss-option" href="#" data-attr_value="">'.__("Any", "swiftframework").'</a>'; $sf_ss_dropdown .= '<i class="fa-check"></i>'; $sf_ss_dropdown .= '</li>'; foreach ($terms as $term) { if ($term->slug == $default_term_id || $term->term_id == $default_term_id) { $sf_ss_dropdown .= '<li class="selected">'; } else { $sf_ss_dropdown .= '<li>'; } if ($option == "product_cat") { $sf_ss_dropdown .= '<a class="ss-option" href="#" data-attr_value="'.$term->slug.'">'.$term->name.'</a>'; } else { $sf_ss_dropdown .= '<a class="ss-option" href="#" data-attr_value="'.$term->term_id.'">'.$term->name.'</a>'; } $sf_ss_dropdown .= '<i class="fa-check"></i>'; $sf_ss_dropdown .= '</li>'; } $sf_ss_dropdown .= '</ul>'; $sf_ss_dropdown .= '</div>'; } return $sf_ss_dropdown; } }
– Kyle
September 15, 2014 at 8:11 am #110550Super Kyle! Many thanks!
September 15, 2014 at 8:26 am #110555Hi,
You most welcome. I’m glad that issue resolved. Thanks Kyle. ๐
With Best Regards
MohammadSeptember 15, 2014 at 8:27 am #110556No problem
– Kyle
September 15, 2014 at 9:48 pm #110944Hi,
Glad I helps ๐
Let us know, if you have any other questions.
Thanks,
laranz.September 16, 2014 at 6:36 am #111011You all support team are just great! Thanks for not having made go to hell yet… ๐
September 16, 2014 at 6:43 am #111012Hi,
Most Welcome. We are very glad that your issues resolved.
Thanks -
Posted in: Dante
You must be logged in and have valid license to reply to this topic.