Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /***************************************
- * /Minimumbestellung 6 Stk und glatt teilbar durch Vielfache von 6 (Modolo 0)
- ***************************************/
- // Set a minimum number of products requirement before checking out
- add_action( 'woocommerce_check_cart_items', 'spyr_set_min_num_products' );
- function spyr_set_min_num_products() {
- // Only run in the Cart or Checkout pages
- if( is_cart() || is_checkout() ) {
- global $woocommerce;
- // Set the minimum number of products before checking out
- $minimum_num_products = 6;
- // Get the Cart's total number of products
- $cart_num_products = WC()->cart->cart_contents_count;
- // Compare values and add an error is Cart's total number of products
- // happens to be less than the minimum required before checking out.
- // Will display a message along the lines of
- // A Minimum of 20 products is required before checking out. (Cont. below)
- // Current number of items in the cart: 6
- if( $cart_num_products < $minimum_num_products || $cart_num_products % 6 != 0) {
- // Display our error message
- wc_add_notice( sprintf( '<strong>Unsere Mindest-Bestellmenge beträgt %s Flaschen. Wir versenden nur Kistenweise, daher muss die Gesamtmenge durch 6 teilbar sein</strong>'
- . '<br />Aktuelle Artikel im Warenkorb: %s.',
- $minimum_num_products,
- $cart_num_products ),
- 'error' );
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement