New Landing How can we help? Themeforest Theme Support Dante Super Search/Personal Shopper: how to limit terms to search for within a list

Viewing 12 posts - 1 through 12 (of 12 total)
  • Posted in: Dante
  • #110337
    alemarengo
    Member
    Post count: 695

    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.
    #110468
    laranz – SUPPORT
    Member
    Post count: 3186

    Hi,

    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.

    #110509
    alemarengo
    Member
    Post count: 695

    Hi 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.
    #110526
    Kyle – SUPPORT
    Moderator
    Post count: 35880

    Hi

    Looks good to me, glad it works ๐Ÿ™‚

    Thanks Laranz

    – Kyle

    #110542
    alemarengo
    Member
    Post count: 695

    Great 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.

    #110546
    Kyle – SUPPORT
    Moderator
    Post count: 35880

    You 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

    #110550
    alemarengo
    Member
    Post count: 695

    Super Kyle! Many thanks!

    #110555
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    You most welcome. I’m glad that issue resolved. Thanks Kyle. ๐Ÿ™‚
    With Best Regards
    Mohammad

    #110556
    Kyle – SUPPORT
    Moderator
    Post count: 35880

    No problem

    – Kyle

    #110944
    laranz – SUPPORT
    Member
    Post count: 3186

    Hi,

    Glad I helps ๐Ÿ™‚

    Let us know, if you have any other questions.

    Thanks,
    laranz.

    #111011
    alemarengo
    Member
    Post count: 695

    You all support team are just great! Thanks for not having made go to hell yet… ๐Ÿ™‚

    #111012
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    Most Welcome. We are very glad that your issues resolved.
    Thanks

Viewing 12 posts - 1 through 12 (of 12 total)

You must be logged in and have valid license to reply to this topic.

License required for one of the following items
Login and Registration Log in · Register