Last active
December 22, 2015 23:39
-
-
Save kloon/6548151 to your computer and use it in GitHub Desktop.
WooCommerce limit total purchased product quantity based on group. Allows customer to only check out when total product quantity are a certain step
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 | |
add_action( 'woocommerce_check_cart_items', 'wc_limit_total_products_purchased_check' ); | |
function wc_limit_total_products_purchased_check() { | |
global $woocommerce; | |
$step = 40; | |
$total_items = $woocommerce->cart->get_cart_contents_count(); | |
if ( $total_items % $step ) | |
$woocommerce->add_error( sprintf( __( 'Your must purchase in groups of %s products, please add or remove products to continue.', 'woocommerce' ), $step ) ); | |
} | |
? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment