• Hi
    Since Woocommerce version 6 and changing the mechanism of product attributes (like color and etc), I couldn’t set the arguments of product attributes via wp_query and it causes me to fetch wrong results in filtering mode.
    and now this is my question, how can I set the product attributes in the query?

    in version 5 of Woocommerce, it was available and we could set it via $wp_query->query_vars. but in version 6 it is not in query_vars.

    for more information, I have brought the generated query of these 2 versions at the bottom.

    wp_query->request of woocommerce v6:

    SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM .... AND .... ( wp _posts.ID IN ( SELECT product_or_parent_id FROM ( SELECT product_or_parent_id FROM wp_wc_product_attributes_lookup lt WHERE term_id in (137) ) temp )) ....

    wp_query->request of woocommerce v5:
    SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts ... AND ( ( SELECT COUNT(1) FROM wp_term_relationships WHERE term_taxonomy_id IN (137) ....

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘unable to set product attributes via wp_query’ is closed to new replies.