pmpro_getLevelCost

The Paid Memberships Pro pmpro getLevelCost function.

Description

pmpro_getLevelCost( &$level, (constant) $tags = true, (constant) $short = false ); 

Parameters (3)

0. $level
The level.
1. $tags — Optional. (constant) => true
The tags.
2. $short — Optional. (constant) => false
The short.

Usage

  1. if ( !function_exists( 'pmpro_getLevelCost' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'paid-memberships-pro/includes/functions.php'; 
  3.  
  4. // The level. 
  5. $level = &$level; 
  6.  
  7. // The tags. 
  8. $tags = true; 
  9.  
  10. // The short. 
  11. $short = false; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = pmpro_getLevelCost($level, $tags, $short); 
  15.  

Defined (1)

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

/includes/functions.php  
  1. function pmpro_getLevelCost(&$level, $tags = true, $short = false) 
  2. //initial payment 
  3. if(!$short) 
  4. $r = sprintf(__('The price for membership is <strong>%s</strong> now', 'paid-memberships-pro' ), pmpro_formatPrice($level->initial_payment)); 
  5. else 
  6. $r = sprintf(__('<strong>%s</strong> now', 'paid-memberships-pro' ), pmpro_formatPrice($level->initial_payment)); 
  7.  
  8. //recurring part 
  9. if($level->billing_amount != '0.00') 
  10. if($level->billing_limit > 1) 
  11. if($level->cycle_number == '1') 
  12. $r .= sprintf(__(' and then <strong>%s per %s for %d more %s</strong>.', 'paid-memberships-pro' ), pmpro_formatPrice($level->billing_amount), pmpro_translate_billing_period($level->cycle_period), $level->billing_limit, pmpro_translate_billing_period($level->cycle_period, $level->billing_limit)); 
  13. else 
  14. $r .= sprintf(__(' and then <strong>%s every %d %s for %d more payments</strong>.', 'paid-memberships-pro' ), pmpro_formatPrice($level->billing_amount), $level->cycle_number, pmpro_translate_billing_period($level->cycle_period, $level->cycle_number), $level->billing_limit); 
  15. elseif($level->billing_limit == 1) 
  16. $r .= sprintf(__(' and then <strong>%s after %d %s</strong>.', 'paid-memberships-pro' ), pmpro_formatPrice($level->billing_amount), $level->cycle_number, pmpro_translate_billing_period($level->cycle_period, $level->cycle_number)); 
  17. else 
  18. if( $level->billing_amount === $level->initial_payment ) { 
  19. if($level->cycle_number == '1') 
  20. if(!$short) 
  21. $r = sprintf(__('The price for membership is <strong>%s per %s</strong>.', 'paid-memberships-pro' ), pmpro_formatPrice($level->initial_payment), pmpro_translate_billing_period($level->cycle_period) ); 
  22. else 
  23. $r = sprintf(__('<strong>%s per %s</strong>.', 'paid-memberships-pro' ), pmpro_formatPrice($level->initial_payment), pmpro_translate_billing_period($level->cycle_period) ); 
  24. else 
  25. if(!$short) 
  26. $r = sprintf(__('The price for membership is <strong>%s every %d %s</strong>.', 'paid-memberships-pro' ), pmpro_formatPrice($level->initial_payment), $level->cycle_number, pmpro_translate_billing_period($level->cycle_period, $level->cycle_number) ); 
  27. else 
  28. $r = sprintf(__('<strong>%s every %d %s</strong>.', 'paid-memberships-pro' ), pmpro_formatPrice($level->initial_payment), $level->cycle_number, pmpro_translate_billing_period($level->cycle_period, $level->cycle_number) ); 
  29. } else { 
  30. if($level->cycle_number == '1') 
  31. $r .= sprintf(__(' and then <strong>%s per %s</strong>.', 'paid-memberships-pro' ), pmpro_formatPrice($level->billing_amount), pmpro_translate_billing_period($level->cycle_period)); 
  32. else 
  33. $r .= sprintf(__(' and then <strong>%s every %d %s</strong>.', 'paid-memberships-pro' ), pmpro_formatPrice($level->billing_amount), $level->cycle_number, pmpro_translate_billing_period($level->cycle_period, $level->cycle_number)); 
  34. else 
  35. $r .= '.'; 
  36.  
  37. //add a space 
  38. $r .= ' '; 
  39.  
  40. //trial part 
  41. if($level->trial_limit) 
  42. if($level->trial_amount == '0.00') 
  43. if($level->trial_limit == '1') 
  44. $r .= ' ' . __('After your initial payment, your first payment is Free.', 'paid-memberships-pro' ); 
  45. else 
  46. $r .= ' ' . sprintf(__('After your initial payment, your first %d payments are Free.', 'paid-memberships-pro' ), $level->trial_limit); 
  47. else 
  48. if($level->trial_limit == '1') 
  49. $r .= ' ' . sprintf(__('After your initial payment, your first payment will cost %s.', 'paid-memberships-pro' ), pmpro_formatPrice($level->trial_amount)); 
  50. else 
  51. $r .= ' ' . sprintf(__('After your initial payment, your first %d payments will cost %s.', 'paid-memberships-pro' ), $level->trial_limit, pmpro_formatPrice($level->trial_amount)); 
  52.  
  53. //taxes part 
  54. $tax_state = pmpro_getOption("tax_state"); 
  55. $tax_rate = pmpro_getOption("tax_rate"); 
  56.  
  57. if($tax_state && $tax_rate && !pmpro_isLevelFree($level)) 
  58. $r .= sprintf(__('Customers in %s will be charged %s%% tax.', 'paid-memberships-pro' ), $tax_state, round($tax_rate * 100, 2)); 
  59.  
  60. if(!$tags) 
  61. $r = strip_tags($r); 
  62.  
  63. $r = apply_filters("pmpro_level_cost_text", $r, $level, $tags, $short); //passing $tags and $short since v1.8 
  64. return $r;