Categories
4 weeks ago
Coupons
4 weeks ago
Customers
2 months ago
Downloads
1 year ago
Export
3 years ago
Import
3 years ago
Orders
4 weeks ago
PerformanceIndicators
9 months ago
Products
4 weeks ago
Revenue
3 months ago
Stock
4 months ago
Taxes
4 weeks ago
Variations
4 weeks ago
Cache.php
4 years ago
Controller.php
11 months ago
DataStore.php
4 weeks ago
DataStoreInterface.php
4 years ago
ExportableInterface.php
4 years ago
ExportableTraits.php
4 years ago
FilteredGetDataTrait.php
1 year ago
GenericController.php
1 year ago
GenericQuery.php
1 year ago
GenericStatsController.php
1 year ago
OrderAwareControllerTrait.php
1 year ago
ParameterException.php
4 years ago
Query.php
1 year ago
Segmenter.php
1 year ago
SqlQuery.php
3 years ago
StatsDataStoreTrait.php
1 year ago
TimeInterval.php
2 years ago
ExportableTraits.php
28 lines
| 1 | <?php |
| 2 | /** |
| 3 | * REST API Reports exportable traits |
| 4 | * |
| 5 | * Collection of utility methods for exportable reports. |
| 6 | */ |
| 7 | |
| 8 | namespace Automattic\WooCommerce\Admin\API\Reports; |
| 9 | |
| 10 | defined( 'ABSPATH' ) || exit; |
| 11 | |
| 12 | /** |
| 13 | * ExportableTraits class. |
| 14 | */ |
| 15 | trait ExportableTraits { |
| 16 | /** |
| 17 | * Format numbers for CSV using store precision setting. |
| 18 | * |
| 19 | * @param string|float $value Numeric value. |
| 20 | * @return string Formatted value. |
| 21 | */ |
| 22 | public static function csv_number_format( $value ) { |
| 23 | $decimals = wc_get_price_decimals(); |
| 24 | // See: @woocommerce/currency: getCurrencyFormatDecimal(). |
| 25 | return number_format( $value, $decimals, '.', '' ); |
| 26 | } |
| 27 | } |
| 28 |