pmpro_checkLevelForBraintreeCompatibility

Checks if PMPro settings are complete or if there are any errors.

Description

pmpro_checkLevelForBraintreeCompatibility( (constant) $level = NULL ); 

Braintree currently does not support: Trial Amounts > 0. Daily or Weekly billing periods. Also check that a plan has been created at Braintree

Parameters (1)

0. $level — Optional. (constant) => NULL
The level.

Usage

  1. if ( !function_exists( 'pmpro_checkLevelForBraintreeCompatibility' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'paid-memberships-pro/adminpages/functions.php'; 
  3.  
  4. // The level. 
  5. $level = NULL; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = pmpro_checkLevelForBraintreeCompatibility($level); 
  9.  

Defined (1)

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

/adminpages/functions.php  
  1. function pmpro_checkLevelForBraintreeCompatibility($level = NULL) 
  2. $gateway = pmpro_getOption("gateway"); 
  3. if($gateway == "braintree") 
  4. global $wpdb; 
  5.  
  6. //check ALL the levels 
  7. if(empty($level)) 
  8. $sqlQuery = "SELECT * FROM $wpdb->pmpro_membership_levelsORDERBY id ASC"; 
  9. $levels = $wpdb->get_results($sqlQuery, OBJECT); 
  10. if(!empty($levels)) 
  11. foreach($levels as $level) 
  12. if(!pmpro_checkLevelForBraintreeCompatibility($level)) 
  13. return false; 
  14. else 
  15. //need to look it up? 
  16. if(is_numeric($level)) 
  17. $level = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->pmpro_membership_levels WHERE id = %d LIMIT 1" , $level ) ); 
  18.  
  19. //check this level 
  20. if($level->trial_amount > 0 || 
  21. ($level->cycle_number > 0 && ($level->cycle_period == "Day" || $level->cycle_period == "Week"))) 
  22. return false; 
  23.  
  24. //check for plan 
  25. if(pmpro_isLevelRecurring($level)) { 
  26. if(!PMProGateway_braintree::checkLevelForPlan($level->id)) 
  27. return false; 
  28.  
  29. return true;