PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 4.3.2
Adminify – White Label, Admin Menu Editor, Login Customizer v4.3.2
4.3.2 4.3.1 4.3.0 4.2.26 4.2.25 4.2.24 4.2.23 4.2.22 4.2.21 4.2.20 4.2.19 4.2.18 4.2.17 4.2.16 4.2.15 4.2.14 4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 4.2.5 All 165 releases
← All changes | Libs/freemius/includes/entities/class-fs-payment.php +62 -4 4.2.134.3.2 View file →
@@ -79,13 +79,24 @@
79 79 * @var int Payment source.
80 80 */
81 81 public $source = 0;
82 82
83 + /**
84 + * Presentment payment information for customer-facing currency display.
85 + *
86 + * @var object|null
87 + */
88 + public $presentment;
89 +
83 90 #endregion Properties
84 91
85 92 const CURRENCY_USD = 'usd';
86 93 const CURRENCY_GBP = 'gbp';
87 94 const CURRENCY_EUR = 'eur';
95 + const CURRENCY_ILS = 'ils';
96 + const CURRENCY_CAD = 'cad';
97 + const CURRENCY_AUD = 'aud';
98 + const CURRENCY_PLN = 'pln';
88 99
89 100 /**
90 101 * @param object|bool $payment
91 102 */
@@ -119,8 +130,46 @@
119 130 return ( 0 != $this->source );
120 131 }
121 132
122 133 /**
134 + * @return bool
135 + */
136 + private function has_presentment()
137 + {
138 + return is_object( $this->presentment );
139 + }
140 +
141 + /**
142 + * @return float
143 + */
144 + private function get_display_gross()
145 + {
146 + return $this->has_presentment() ?
147 + (float) $this->presentment->gross :
148 + (float) $this->gross;
149 + }
150 +
151 + /**
152 + * @return float
153 + */
154 + private function get_display_vat()
155 + {
156 + return $this->has_presentment() ?
157 + (float) $this->presentment->vat :
158 + (float) $this->vat;
159 + }
160 +
161 + /**
162 + * @return string
163 + */
164 + private function get_display_currency()
165 + {
166 + return $this->has_presentment() ?
167 + $this->presentment->currency :
168 + $this->currency;
169 + }
170 +
171 + /**
123 172 * Returns the gross in this format:
124 173 * `{symbol}{amount | 2 decimal digits} {currency | uppercase}`
125 174 *
126 175 * Examples: £9.99 GBP, -£9.99 GBP.
@@ -131,14 +180,15 @@
131 180 * @return string
132 181 */
133 182 function formatted_gross()
134 183 {
135 - $price = $this->gross + $this->vat;
184 + $price = $this->get_display_gross() + $this->get_display_vat();
185 +
136 186 return (
137 187 ( $price < 0 ? '-' : '' ) .
138 188 $this->get_symbol() .
139 189 number_format( abs( $price ), 2, '.', ',' ) . ' ' .
140 - strtoupper( $this->currency )
190 + strtoupper( $this->get_display_currency() )
141 191 );
142 192 }
143 193
144 194 /**
@@ -160,10 +210,18 @@
160 210 self::$CURRENCY_2_SYMBOL = array(
161 211 self::CURRENCY_USD => '$',
162 212 self::CURRENCY_GBP => '&pound;',
163 213 self::CURRENCY_EUR => '&euro;',
214 + self::CURRENCY_ILS => '₪',
215 + self::CURRENCY_CAD => '$',
216 + self::CURRENCY_AUD => '$',
217 + self::CURRENCY_PLN => 'zł',
164 218 );
165 219 }
166 220
167 - return self::$CURRENCY_2_SYMBOL[ $this->currency ];
221 + $currency = $this->get_display_currency();
222 +
223 + return isset( self::$CURRENCY_2_SYMBOL[ $currency ] )
224 + ? self::$CURRENCY_2_SYMBOL[ $currency ]
225 + : strtoupper( $currency ) . ' ';
168 226 }
169 - }
227 + }