Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Setting minimum quantity when adding the product to cart from shop page.
<?php
function loop_add_to_cart_args_callback( $args, $product ) {
$product_id = $product->get_id();
$product_min = wc_get_product_min_limit( $product_id );
if ( $product_min ) {
$args['quantity'] = $product_min;
}
return $args;
}
add_filter( 'woocommerce_loop_add_to_cart_args', 'loop_add_to_cart_args_callback', 100, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment