Get all product variations by category
-
I need to get all Woocommerce product variations that belongs to selected category. I tried to query that this way:
$args = array( 'post_type' => 'product_variation', 'post_status' => array('private', 'publish'), 'tax_query' => array( array( 'taxonomy' => 'product_cat', 'field' => 'term_id', 'terms' => $selected_category_id ) ) ); $variations = get_posts( $args );
but “tax_query” part seems to be ignored and no matter what will be provided inside, it does not affect the query.
Any ideas how to do that?
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Get all product variations by category’ is closed to new replies.