Public Ticket #3831369

Quantity input field on product catalogue page

Closed
Comments
5 Tickets 1
John started the conversation 2 years ago on March 4, 2025 at 12:15am

Is there an option to add a quantity input field under each product on the product catalogue/category pages? It would ideally respect all the tiered pricing and default to the correct minimum order quantity if set up.

i.e. Instead of the "Add to cart" adding one product, it would add whatever amount is input in this field.

It wouldn't need to be apply for any products with variants.

2,762
KingsPlugins replied 2 years ago on March 6, 2025 at 6:29pm

Hello John, 

By default our plugin does not have any features for this.

 

I believe this depends a lot on the theme. It may be possible to achieve it using a code snippet but I'm not certain the same snippet would work with all themes. 

This code can add that kind of qty input field for simple products in my tests:

add_filter( 'woocommerce_loop_add_to_cart_link', 'quantity_inputs_for_woocommerce_loop_add_to_cart_link', 10, 2 );
function quantity_inputs_for_woocommerce_loop_add_to_cart_link( $html, $product ) {
	if ( $product && $product->is_type( 'simple' ) && $product->is_purchasable() && $product->is_in_stock() && ! $product->is_sold_individually() ) {
		$html = '<form action="' . esc_url( $product->add_to_cart_url() ) . '" class="cart" method="post" enctype="multipart/form-data">';
		$html .= woocommerce_quantity_input( array(), $product, false );
		$html .= '<button type="submit" class="button alt">' . esc_html( $product->add_to_cart_text() ) . '</button>';
		$html .= '</form>';
	}
	return $html;
}

This can be added to functions.php or any snippets plugin. 

 

Kind regards,

Stefan

5 Tickets 1
John replied 2 years ago on March 7, 2025 at 6:24am

Hi Stefan,

Thanks for letting me know.

I did find that code online elsewhere and briefly tested it with Astra theme.

It seemed to work but I've since removed the feature as it was no longer needed.

1

Sign In