wcpgsk_globalqty_cart_update

The Woocommerce Poor Guys Swiss Knife wcpgsk globalqty cart update function.

Description

wcpgsk_globalqty_cart_update( $valid, $cart_item_key, $values, $quantity ); 

Parameters (4)

0. $valid
The valid.
1. $cart_item_key
The cart item key.
2. $values
The values.
3. $quantity
The quantity.

Usage

  1. if ( !function_exists( 'wcpgsk_globalqty_cart_update' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce-poor-guys-swiss-knife/wcpgsk-af.php'; 
  3.  
  4. // The valid. 
  5. $valid = null; 
  6.  
  7. // The cart item key. 
  8. $cart_item_key = null; 
  9.  
  10. // The values. 
  11. $values = null; 
  12.  
  13. // The quantity. 
  14. $quantity = null; 
  15.  
  16. // NOTICE! Understand what this does before running. 
  17. $result = wcpgsk_globalqty_cart_update($valid, $cart_item_key, $values, $quantity); 
  18.  

Defined (1)

The function is defined in the following location(s).

/wcpgsk-af.php  
  1. function wcpgsk_globalqty_cart_update( $valid, $cart_item_key, $values, $quantity ) {  
  2. global $woocommerce; 
  3. $options = get_option( 'wcpgsk_settings' ); 
  4. $maxqtycart = isset( $options['cart']['maxqtycart'] ) ? $options['cart']['maxqtycart'] : 0; 
  5. $minqtycart = isset( $options['cart']['minqtycart'] ) ? $options['cart']['minqtycart'] : 0; 
  6. $qtycnt = 0; 
  7. $prodcnt = 0; 
  8. foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $values ) : 
  9. $qtycnt += $values['quantity']; 
  10. $prodcnt++; 
  11. endforeach; 
  12. if ( $maxqtycart && is_numeric($maxqtycart) && $qtycnt > $maxqtycart ) :  
  13. wcpgsk_add_message( sprintf( __( 'The overall sum for all product quantities is restricted to %s in this shop. Your overall quantity sum: %s. Please buy less quantity at least for some products.', WCPGSK_DOMAIN ), $maxqtycart, $qtycnt ) ); 
  14. endif; 
  15. if ( $minqtycart && is_numeric($minqtycart) && $qtycnt < $minqtycart ) :  
  16. wcpgsk_add_message( sprintf( __( 'The required minimum sum for all product quantities is set to %s in this shop. Your overall quantity sum: %s. You have to add products to your cart or buy existing products in a higher quantity.', WCPGSK_DOMAIN ), $minqtycart, $qtycnt ) ); 
  17. endif; 
  18. return $valid;