Setting minimum quantity when adding the product to cart from shop page.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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