Problem is on cart page has_term
is false
because it is checking if cart page have terms 12-pack
or 6-pack
. You also need to provide post object/ID to has_term()
as a third parameter.
Updated code:-
function input_set_all_values( $args, $product ) {
if (( has_term('6-pack', 'criteria', $product->post ) ) ) {
$args['step'] = 6;
$args['min_value'] = 6;
return $args;
} else if (( has_term('12-pack', 'criteria', $product->post ) ) ) {
$args['step'] = 12;
$args['min_value'] = 12;
return $args;
} else {
$args['step'] = 1;
$args['min_value'] = 1;
return $args;
}
}