Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter mjb709

    (@mjb709)

    Looks like I found a solution for anyone who wants to have JUST the tags be the common link for related products.

    I edited the file /woocommerce/classes/class-wc-products.php

    This is pasted starting at line 1192, I commented out a couple of lines.

    // Related products are found from category and tag
    		$tags_array = array(0);
    		/* $cats_array = array(0); */ /* <-- commented out this line */
    
    		// Get tags
    		$terms = wp_get_post_terms($this->id, 'product_tag');
    		foreach ($terms as $term) $tags_array[] = $term->term_id;
    
    		// Get categories
    		/* $terms = wp_get_post_terms($this->id, 'product_cat');
    		foreach ($terms as $term) $cats_array[] = $term->term_id; */  /* <-- and commented out this line */
    
    		// Don't bother if none are set
    		if ( sizeof($cats_array)==1 && sizeof($tags_array)==1 ) return array();

    If anyone knows how to make what I’ve done into a line of code to copy to my own theme’s functions.php that would be great since now if I upgrade, I’ll have to manually edit this out again.

    mjb709

    (@mjb709)

    bumped.
    For example, if a product title is “The Smiths”, how do I cut out the word “The” when it is organizing the product alphabetically so it’s in the “S” section and not “T” section?

Viewing 2 replies - 1 through 2 (of 2 total)