BladeOne.php
2 years ago
CSV.php
2 years ago
Currency.php
2 years ago
Device.php
2 years ago
Dir.php
2 years ago
Number_Formatter.php
2 years ago
Request.php
2 years ago
Salt.php
2 years ago
Security.php
2 years ago
Server.php
2 years ago
Singleton.php
2 years ago
String_Util.php
2 years ago
URL.php
2 years ago
WP_Async_Request.php
2 years ago
WordPress_Site_Date_Format_Pattern.php
2 years ago
Currency.php
29 lines
| 1 | <?php |
| 2 | |
| 3 | namespace IAWP\Utils; |
| 4 | |
| 5 | /** @internal */ |
| 6 | class Currency |
| 7 | { |
| 8 | /** |
| 9 | * Format currency for sites using WooCommerce |
| 10 | * |
| 11 | * @param mixed $amount |
| 12 | * @param bool $round_to_whole_dollars |
| 13 | * |
| 14 | * @return string |
| 15 | */ |
| 16 | public static function format($amount, bool $round_to_whole_dollars = \true, bool $strip_tags = \true) : string |
| 17 | { |
| 18 | if (!\function_exists('wc_price')) { |
| 19 | return $amount; |
| 20 | } |
| 21 | if ($round_to_whole_dollars) { |
| 22 | $options = ['decimals' => 0]; |
| 23 | } else { |
| 24 | $options = null; |
| 25 | } |
| 26 | return $strip_tags ? \strip_tags(\wc_price($amount, $options)) : \wc_price($amount, $options); |
| 27 | } |
| 28 | } |
| 29 |