FS_Pricing

The NextGEN Gallery FS Pricing class.

Defined (1)

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

/freemius/includes/entities/class-fs-pricing.php  
  1. class FS_Pricing extends FS_Entity { 
  2.  
  3. #region Properties 
  4.  
  5. /** 
  6. * @var number 
  7. */ 
  8. public $plan_id; 
  9. /** 
  10. * @var int 
  11. */ 
  12. public $licenses; 
  13. /** 
  14. * @var null|float 
  15. */ 
  16. public $monthly_price; 
  17. /** 
  18. * @var null|float 
  19. */ 
  20. public $annual_price; 
  21. /** 
  22. * @var null|float 
  23. */ 
  24. public $lifetime_price; 
  25.  
  26. #endregion Properties 
  27.  
  28. /** 
  29. * @param object|bool $pricing 
  30. */ 
  31. function __construct( $pricing = false ) { 
  32. parent::__construct( $pricing ); 
  33.  
  34. static function get_type() { 
  35. return 'pricing'; 
  36.  
  37. /** 
  38. * @author Vova Feldman (@svovaf) 
  39. * @since 1.1.8 
  40. * @return bool 
  41. */ 
  42. function has_monthly() { 
  43. return ( is_numeric( $this->monthly_price ) && $this->monthly_price > 0 ); 
  44.  
  45. /** 
  46. * @author Vova Feldman (@svovaf) 
  47. * @since 1.1.8 
  48. * @return bool 
  49. */ 
  50. function has_annual() { 
  51. return ( is_numeric( $this->annual_price ) && $this->annual_price > 0 ); 
  52.  
  53. /** 
  54. * @author Vova Feldman (@svovaf) 
  55. * @since 1.1.8 
  56. * @return bool 
  57. */ 
  58. function has_lifetime() { 
  59. return ( is_numeric( $this->lifetime_price ) && $this->lifetime_price > 0 ); 
  60.  
  61. /** 
  62. * Check if unlimited licenses pricing. 
  63. * @author Vova Feldman (@svovaf) 
  64. * @since 1.1.8 
  65. * @return bool 
  66. */ 
  67. function is_unlimited() { 
  68. return is_null( $this->licenses ); 
  69.  
  70.  
  71. /** 
  72. * Check if pricing has more than one billing cycle. 
  73. * @author Vova Feldman (@svovaf) 
  74. * @since 1.1.8 
  75. * @return bool 
  76. */ 
  77. function is_multi_cycle() { 
  78. $cycles = 0; 
  79. if ( $this->has_monthly() ) { 
  80. $cycles ++; 
  81. if ( $this->has_annual() ) { 
  82. $cycles ++; 
  83. if ( $this->has_lifetime() ) { 
  84. $cycles ++; 
  85.  
  86. return $cycles > 1; 
  87.  
  88. /** 
  89. * Get annual over monthly discount. 
  90. * @author Vova Feldman (@svovaf) 
  91. * @since 1.1.8 
  92. * @return int 
  93. */ 
  94. function annual_discount_percentage() { 
  95. return floor( $this->annual_savings() / ( $this->monthly_price * 12 * ( $this->is_unlimited() ? 1 : $this->licenses ) ) * 100 ); 
  96.  
  97. /** 
  98. * Get annual over monthly savings. 
  99. * @author Vova Feldman (@svovaf) 
  100. * @since 1.1.8 
  101. * @return float 
  102. */ 
  103. function annual_savings() { 
  104. return ( $this->monthly_price * 12 - $this->annual_price ) * ( $this->is_unlimited() ? 1 : $this->licenses ); 
  105.