Cant seem to figure this out with if statements. Wanting it to show QTY 4 unless stock available is less than 4..
So far I have this..
function wpse_292293_quantity_input_default( $args, $product ) {
$args['max_value'] = $product->managing_stock() ? $product->get_stock_quantity() : 100;
$args['input_value'] = 4;
return $args;
}
add_filter( 'woocommerce_quantity_input_args', 'wpse_292293_quantity_input_default', 10, 2 );
CodePudding user response:
Wanting it to show QTY 4 unless stock available is less than 4..
So that would be the minimum of the actual available stock, and 4.
$args['input_value'] = min(4, $product->get_stock_quantity());