Site icon Experience Wordpress Developer Online – Design Develop and Maintenance Support

Woocommerce add quantity field in shop page

As there is no default way in WooCommerce to add the quantity field to the archive page, we’ve created a code snippet that you can use and it will work instantly.

Add this following line of code at the end of your theme’s functions.php file of your active child theme (or theme) and Save the file.

add_filter( 'woocommerce_loop_add_to_cart_link', 'quantity_inputs_for_woocommerce_loop', 10, 2 );
function quantity_inputs_for_woocommerce_loop( $html, $product ) {
	if ( $product && $product->is_type( 'simple' ) && $product->is_purchasable() && $product->is_in_stock() && ! $product->is_sold_individually() ) {
        $html .= woocommerce_quantity_input( array(), $product, false );
	}
	return $html;
}


Exit mobile version