Viewing 7 replies - 1 through 7 (of 7 total)
  • Caleb Burks

    (@icaleb)

    Automattic Happiness Engineer

    Hi Sadegh,

    Might want to look into using a custom “related posts” plugin then. Or if you want to be particular about what is shown there, you can disable related products and instead use manually input up-sells for this.

    It should be possible to use this filter though to return 0 tags when the related query is being built: https://github.com/woothemes/woocommerce/blob/master/includes/abstracts/abstract-wc-product.php#L1565

    Thread Starter Sadegh Hosseini

    (@mr-seven)

    Hi Caleb and thanks for your answer.
    I’ve edited woocommerce/includes/abstracts/abstract-wc-product.php and deleted this line(1303):
    $tags_array = $this->get_related_terms( ‘product_tag’ );
    But it doesn’t solve my problem.

    about custom “related posts” plugin, my store is a multi vendor store and I can’t do it manually.

    Plugin Contributor Mike Jolley

    (@mikejolley)

    Thread Starter Sadegh Hosseini

    (@mr-seven)

    Thanks a lot Mike.

    @mikejolley I know this thread’s a few months old at this point, but perhaps you can help me out. The solution on that link isn’t working for me. Do you know if these snippets work in WC 2.4.12?

    /**
     * Does not filter related products by tag
     */
    add_filter( 'woocommerce_product_related_posts_relate_by_tag', '__return_false' );
    
    /**
     * Does not filter related products by category
     */
    add_filter( 'woocommerce_product_related_posts_relate_by_category', '__return_false' );

    My end goal will be to show related products that share a tag with the one being viewed, but filter out any that have a specific tag, “Discontinued”. That way when you view Widget A 2.0, you also see Widget B 2.0 but NOT Widget B 1.0.

    Plugin Contributor Mike Jolley

    (@mikejolley)

    I don’t think so – woocommerce_product_related_posts_relate_by_tag is a newer filter.

    johnny538

    (@johnny538)

    Sorry for bringing up an old thread but does this snippet still work ? And would it work on subcategories ? Mine look like “Women>Shoes>Boots” and “Women>Bags>Handbags”, and for some reason handbags still appear as related products when viewing any kind of shoe…

    Update: I wanted to add that all categories seem to show a different category in related products. Mens shoes show only womens shoes, womens shoes only shows handbags. Bags do show only bags though.

    • This reply was modified 8 years ago by johnny538.
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘woocommerce related products only by category’ is closed to new replies.