/var/www/html_uk/wp-content/plugins/automatewoo/includes/Variables/Abstract_Price.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php

namespace AutomateWoo;

defined'ABSPATH' ) || exit;

/**
 * Variable Abstract Price Class.
 *
 * @since 4.5.0
 *
 * @class Variable_Abstract_Price
 */
abstract class Variable_Abstract_Price extends Variable {

    
/**
     * Load Admin Details.
     */
    
public function load_admin_details() {
        
$this->add_parameter_select_field(
            
'format',
            
__'Choose to display the amount as a formatted price or numerical value.''automatewoo' ),
            [
                
''        => __'Price''automatewoo' ),
                
'decimal' => __'Decimal''automatewoo' ),
            ],
            
false
        
);
    }

    
/**
     * Maybe Format Price.
     *
     * @param  string $amount
     * @param  array  $parameters
     * @param  string $currency
     *
     * @return string
     */
    
protected function format_amount$amount$parameters$currency null ) {

        
$format = isset( $parameters['format'] ) ? $parameters['format'] : 'price';

        switch ( 
$format ) {
            case 
'decimal':
                return 
wc_format_localized_priceFormat::decimal$amount ) );
            default:
                return 
wc_price$amount, [ 'currency' => $currency ] );
        }
    }
}