WooCommerce: Edit Add to Cart Min, Max & Step Quantity

115

PHP Snippet 1: Set Min, Max, Increment & Start Value Add to Cart Quantity @ WooCommerce Single Product Page & Cart Page (Simple Products)

add_filter( ‘woocommerce_quantity_input_args’, ‘bloomer_woocommerce_quantity_changes’, 10, 2 );

function bloomer_woocommerce_quantity_changes( $args, $product ) {

if ( ! is_cart() ) {

$args[‘input_value’] = 4; // Start from this value (default = 1)
$args[‘max_value’] = 10; // Max quantity (default = -1)
$args[‘min_value’] = 4; // Min quantity (default = 0)
$args[‘step’] = 2; // Increment/decrement by this value (default = 1)

} else {

// Cart’s “min_value” is already 0 and we don’t need “input_value”
$args[‘max_value’] = 10; // Max quantity (default = -1)
$args[‘step’] = 2; // Increment/decrement by this value (default = 0)
// COMMENT OUT FOLLOWING IF STEP < MIN_VALUE
// $args[‘min_value’] = 4; // Min quantity (default = 0)

}

return $args;

}

PHP Snippet 2: Set Min Add to Cart Quantity @ WooCommerce Single Product Page (Variable Products -> Single Variation)

add_filter( ‘woocommerce_available_variation’, ‘bloomer_woocommerce_quantity_min_variation’, 9999, 3 );

function bloomer_woocommerce_quantity_min_variation( $args, $product, $variation ) {
$args[‘min_qty’] = 5;
return $args;
}

Social Media Auto Publish Powered By : XYZScripts.com