Support » Plugin: WooCommerce » Grouped product and default quantity

  • Resolved marknopfler

    (@marknopfler)


    Hello! I have a grouped product with 15 products inside. The quantities of each product in the grouped product is default to zero, meaning that people have to change the quantity 15 times. How can I set quantity to 1 to all the 15 products?
    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Rynald0s.a11n

    (@rynald0s)

    Automattic Happiness Engineer

    Hi @marknopfler!

    You could use the following to see if that helps:

    add_filter( 'woocommerce_quantity_input_args', 'custom_quantity', 10, 2 );
    function custom_quantity( $args, $product ) {
        $args['input_value'] = 1;
        return $args;
    }

    You can read more about how to add this code to your site here:

    http://rynaldo.com/how-to-add-custom-code-to-your-woocommerce-wordpress-site-the-right-way/

    Ps. Great fan of Mark Knopfler 😀

    Cheers!

    Thread Starter marknopfler

    (@marknopfler)

    Oh it works!
    You made my day!
    Knopfler appreciates you! 😉

    Plugin Support Rynald0s.a11n

    (@rynald0s)

    Automattic Happiness Engineer

    Haha! Nice!

    Have a good one, Mark!

    Thread Starter marknopfler

    (@marknopfler)

    Hi @rynald0s,
    The code works for Grouped Products but when I goto Cart page it allways shows “1” on Quantity. If I update cart with “2” it updates the subtotal but it shows “1” on Quantity.
    Is there any way that the code work only for Grouped Products and not on cart page?
    Thanks!!!

    Thread Starter marknopfler

    (@marknopfler)

    A quick solution if someone needs it:

    add_filter( 'woocommerce_quantity_input_args', 'custom_quantity', 10, 2 );
    function custom_quantity( $args, $product ) {
        if (is_page(8)) {
        return $args;
    	} else {
    	$args['input_value'] = 1;
        return $args;
    	}
    }

    Just modify the id 8 (is_page(8)) for your cart ID page

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Grouped product and default quantity’ is closed to new replies.