Minimum and step quantity product based on attribute - product page and cart

27 views Asked by At

Good morning, I am trying to set a minimum value and quantity steps of products based on an attribute using this code :

add_filter( 'woocommerce_quantity_input_args', 'jk_woocommerce_quantity_input_args', 10, 2 ); // Simple products

function jk_woocommerce_quantity_input_args( $args, $product ) {
    if ( is_singular( 'product' ) ) {
        $args['input_value']    = 2;    // Starting value (we only want to affect product pages, not cart)
    }
    $args['max_value']  = 80;   // Maximum value
    $args['min_value']  = 2;    // Minimum value
    $args['step']       = 2;    // Quantity steps
    return $args;
}

But only affects the product pages and not the cart.

Can anyone help me?

Thank you

I need to customize the code in order to affects the cart too

0

There are 0 answers