wcpgsk_qtyselector_max

The Woocommerce Poor Guys Swiss Knife wcpgsk qtyselector max function.

Description

wcpgsk_qtyselector_max( $whatever, (null) $product = null ); 

Parameters (2)

0. $whatever
The whatever.
1. $product — Optional. (null) => null
The product.

Usage

  1. if ( !function_exists( 'wcpgsk_qtyselector_max' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce-poor-guys-swiss-knife/wcpgsk-af.php'; 
  3.  
  4. // The whatever. 
  5. $whatever = null; 
  6.  
  7. // The product. 
  8. $product = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = wcpgsk_qtyselector_max($whatever, $product); 
  12.  

Defined (1)

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

/wcpgsk-af.php  
  1. function wcpgsk_qtyselector_max( $whatever, $product = null ) { 
  2. if ( isset( $product ) && is_object( $product ) ) : 
  3. global $wcpgsk_session; 
  4. $options = get_option( 'wcpgsk_settings' );  
  5. if ( $product->is_sold_individually() ) : 
  6. $maxqty = 1; 
  7. else : 
  8. $maxqty = isset($options['cart']['maxqty_' . $product->product_type]) && $options['cart']['maxqty_' . $product->product_type] != 0 ? $options['cart']['maxqty_' . $product->product_type] : '';  
  9. if ( isset($options['cart']['minmaxstepproduct']) && $options['cart']['minmaxstepproduct'] == 1 ) : 
  10. $product_id = $product->post->ID;  
  11. $maxval = get_post_meta($product_id, '_wcpgsk_maxqty', true); 
  12. if ( isset($maxval) && $maxval > 0 ) : 
  13. $maxqty = $maxval; 
  14. endif; 
  15. endif; 
  16. if ($maxqty == '' && isset($wcpgsk_session->qtyargs['max_value']) ) { 
  17. $maxqty = $wcpgsk_session->qtyargs['max_value']; 
  18. endif; 
  19. return $maxqty; 
  20. else : 
  21. return $whatever; 
  22. endif;