PluginProbe
Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder / 1.5
Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder v1.5
3.6.0 3.5.0 trunk 1.0.10 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.6.1 1.0.7 1.0.8 1.0.9 1.1 1.1.1 1.2 1.3 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.5 1.5.1 All 110 releases
buttonizer-multifunctional-button / freemius / includes / entities / class-fs-pricing.php

class-fs-pricing.php in Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder 1.5, at freemius/includes/entities/class-fs-pricing.php

141 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package Freemius for EDD Add-On
4 * @copyright Copyright (c) 2015, Freemius, Inc.
5 * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
6 * @since 1.0.0
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit;
11 }
12
13 class FS_Pricing extends FS_Entity {
14
15 #region Properties
16
17 /**
18 * @var number
19 */
20 public $plan_id;
21 /**
22 * @var int
23 */
24 public $licenses;
25 /**
26 * @var null|float
27 */
28 public $monthly_price;
29 /**
30 * @var null|float
31 */
32 public $annual_price;
33 /**
34 * @var null|float
35 */
36 public $lifetime_price;
37
38 #endregion Properties
39
40 /**
41 * @param object|bool $pricing
42 */
43 function __construct( $pricing = false ) {
44 parent::__construct( $pricing );
45 }
46
47 static function get_type() {
48 return 'pricing';
49 }
50
51 /**
52 * @author Vova Feldman (@svovaf)
53 * @since 1.1.8
54 *
55 * @return bool
56 */
57 function has_monthly() {
58 return ( is_numeric( $this->monthly_price ) && $this->monthly_price > 0 );
59 }
60
61 /**
62 * @author Vova Feldman (@svovaf)
63 * @since 1.1.8
64 *
65 * @return bool
66 */
67 function has_annual() {
68 return ( is_numeric( $this->annual_price ) && $this->annual_price > 0 );
69 }
70
71 /**
72 * @author Vova Feldman (@svovaf)
73 * @since 1.1.8
74 *
75 * @return bool
76 */
77 function has_lifetime() {
78 return ( is_numeric( $this->lifetime_price ) && $this->lifetime_price > 0 );
79 }
80
81 /**
82 * Check if unlimited licenses pricing.
83 *
84 * @author Vova Feldman (@svovaf)
85 * @since 1.1.8
86 *
87 * @return bool
88 */
89 function is_unlimited() {
90 return is_null( $this->licenses );
91 }
92
93
94 /**
95 * Check if pricing has more than one billing cycle.
96 *
97 * @author Vova Feldman (@svovaf)
98 * @since 1.1.8
99 *
100 * @return bool
101 */
102 function is_multi_cycle() {
103 $cycles = 0;
104 if ( $this->has_monthly() ) {
105 $cycles ++;
106 }
107 if ( $this->has_annual() ) {
108 $cycles ++;
109 }
110 if ( $this->has_lifetime() ) {
111 $cycles ++;
112 }
113
114 return $cycles > 1;
115 }
116
117 /**
118 * Get annual over monthly discount.
119 *
120 * @author Vova Feldman (@svovaf)
121 * @since 1.1.8
122 *
123 * @return int
124 */
125 function annual_discount_percentage() {
126 return floor( $this->annual_savings() / ( $this->monthly_price * 12 * ( $this->is_unlimited() ? 1 : $this->licenses ) ) * 100 );
127 }
128
129 /**
130 * Get annual over monthly savings.
131 *
132 * @author Vova Feldman (@svovaf)
133 * @since 1.1.8
134 *
135 * @return float
136 */
137 function annual_savings() {
138 return ( $this->monthly_price * 12 - $this->annual_price ) * ( $this->is_unlimited() ? 1 : $this->licenses );
139 }
140
141 }