Skip to content

Loading…

Related Products ordered by category #428

Closed
Valdimarsson opened this Issue · 4 comments

4 participants

@Valdimarsson

How do I get the Related Products to order by category that the current product is located in?
What I want to do is; have the Related Products under product summary to show products from the same category that the current product is at?

I found a function in woocommerce_template_functions.php on line 640 where it calls for function woocommerce_related_products. But I have no clue whatsoever to where I should change the code.

If somebody out there has a tweak for this I would be greatful. Thanks

@Valdimarsson

Isn't it at all possible?

@mikejolley
WooThemes member

Related posts already have that:

'tax_query' => array(
'relation' => 'OR',
array(
'taxonomy' => 'product_cat',
'field' => 'id',
'terms' => $cats_array
),
array(
'taxonomy' => 'product_tag',
'field' => 'id',
'terms' => $tags_array
)
)

They find products with the same product category or product tag, and them randomise the result. In the next version the above query will be filterable via a hook ('woocommerce_product_related_posts').

@mikejolley mikejolley closed this
@calvary21concepts

great post, mike, where does this go in the code? sorry, cant seem to get it to work in the template

@ryukyuman

I also need this information, but I need to figure out how to refine the product category down to it's "smallest" category. Currently I am getting randomized results from my entire shopping cart.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.