Skip to content

Commit

Permalink
Modify the code to never store the Currency code in the class.
Browse files Browse the repository at this point in the history
  • Loading branch information
bordoni committed Nov 16, 2021
1 parent 654977c commit 9d741bd
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/Tribe/Commerce/Currency.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ class Tribe__Tickets__Commerce__Currency {

/**
* @var string
*
* @depreacated TBD
*/
public $currency_code;

Expand All @@ -16,7 +18,6 @@ class Tribe__Tickets__Commerce__Currency {
* @since 4.7
*/
public function __construct() {
$this->currency_code = tribe_get_option( 'ticket-commerce-currency-code', 'USD' );
$this->generate_default_currency_map();
}

Expand Down Expand Up @@ -44,7 +45,7 @@ public function hook( ) {
* @return string
*/
public function get_currency_symbol( $post_id = null, $decode = false ) {
$symbol = $this->currency_code_options_map[ $this->currency_code ]['symbol'];
$symbol = $this->currency_code_options_map[ $this->get_currency_code() ]['symbol'];
$symbol = apply_filters( 'tribe_commerce_currency_symbol', $symbol, $post_id );

return $decode ? html_entity_decode( $symbol ) : $symbol;
Expand Down Expand Up @@ -98,10 +99,10 @@ public function filter_currency_cost( $cost = '', $post_id = 0 ) {
* @return string
*/
public function get_currency_symbol_position( $post_id = null ) {
if ( ! isset( $this->currency_code_options_map[ $this->currency_code ]['position'] ) ) {
if ( ! isset( $this->currency_code_options_map[ $this->get_currency_code() ]['position'] ) ) {
$currency_position = 'prefix';
} else {
$currency_position = $this->currency_code_options_map[ $this->currency_code ]['position'];
$currency_position = $this->currency_code_options_map[ $this->get_currency_code() ]['position'];
}

if (
Expand Down Expand Up @@ -538,7 +539,7 @@ public function get_provider_symbol_position( $provider, $object_id ) {
* @return string
*/
public function get_currency_locale( $key, $currency_code = null ) {
$currency_code = null === $currency_code ? $this->currency_code : strtoupper( $currency_code );
$currency_code = null === $currency_code ? $this->get_currency_code() : strtoupper( $currency_code );

$default = reset( $this->currency_code_options_map );
$currency_data = Tribe__Utils__Array::get( $this->currency_code_options_map, $currency_code, $default );
Expand Down Expand Up @@ -604,7 +605,7 @@ public function get_symbols_for_codes( $codes ) {
* e.g. "USD".
*/
public function get_currency_code() {
return $this->currency_code;
return tribe_get_option( 'ticket-commerce-currency-code', 'USD' );
}

/**
Expand Down

0 comments on commit 9d741bd

Please sign in to comment.