'args[max_input] woocommerce if statement confused

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 );


Solution 1:[1]

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());

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 CBroe