I’m trying to do a woocommerce query that results in all products that have the custom attribute Height that are in a specific range.
function testing_woo_product_query($q)
{
$min_height = 1;
$max_height = 5;
//Product custom attribute Height, get all products between min_height and max_height
$q->set("tax_query", array(
"relation" => 'AND',
array(
"taxonomy" => "Height",
"field" => "slug",
"terms" => array($min_height),
"operator" => ">="
),
array(
"taxonomy" => "Height",
"field" => "slug",
"terms" => array($max_height),
"operator" => "<="
)
));
}
add_action("woocommerce_product_query", "testing_woo_product_query");