pmpro_getCheckoutButton

The Paid Memberships Pro pmpro getCheckoutButton function.

Description

pmpro_getCheckoutButton( $level_id, (constant) $button_text = NULL, (constant) $classes = NULL ); 

Parameters (3)

0. $level_id
The level id.
1. $button_text — Optional. (constant) => NULL
The button text.
2. $classes — Optional. (constant) => NULL
The classes.

Usage

  1. if ( !function_exists( 'pmpro_getCheckoutButton' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'paid-memberships-pro/includes/functions.php'; 
  3.  
  4. // The level id. 
  5. $level_id = null; 
  6.  
  7. // The button text. 
  8. $button_text = NULL; 
  9.  
  10. // The classes. 
  11. $classes = NULL; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = pmpro_getCheckoutButton($level_id, $button_text, $classes); 
  15.  

Defined (1)

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

/includes/functions.php  
  1. function pmpro_getCheckoutButton($level_id, $button_text = NULL, $classes = NULL) 
  2. if(empty($button_text)) 
  3. $button_text = __("Sign Up for !!name!! Now", 'paid-memberships-pro' ); 
  4.  
  5. if(empty($classes)) 
  6. $classes = "pmpro_btn"; 
  7.  
  8. if(empty($level_id)) 
  9. $r = __("Please specify a level id.", 'paid-memberships-pro' ); 
  10. else 
  11. //get level 
  12. $level = pmpro_getLevel($level_id); 
  13.  
  14. //replace vars 
  15. $replacements = array( 
  16. "!!id!!" => $level->id,  
  17. "!!name!!" => $level->name,  
  18. "!!description!!" => $level->description,  
  19. "!!confirmation!!" => $level->confirmation,  
  20. "!!initial_payment!!" => $level->initial_payment,  
  21. "!!billing_amount!!" => $level->billing_amount,  
  22. "!!cycle_number!!" => $level->cycle_number,  
  23. "!!cycle_period!!" => $level->cycle_period,  
  24. "!!billing_limit!!" => $level->billing_limit,  
  25. "!!trial_amount!!" => $level->trial_amount,  
  26. "!!trial_limit!!" => $level->trial_limit,  
  27. "!!expiration_number!!" => $level->expiration_number,  
  28. "!!expiration_period!!" => $level->expiration_period 
  29. ); 
  30. $button_text = str_replace(array_keys($replacements), $replacements, $button_text); 
  31.  
  32. //button text 
  33. $r = "<a href=\"" . pmpro_url("checkout", "?level=" . $level_id) . "\" class=\"" . $classes . "\">" . $button_text . "</a>"; 
  34. return $r;