alg_tcmb_get_exchange_rate_TRY

Alg_tcmb_get_exchange_rate_TRY.

Description

alg_tcmb_get_exchange_rate_TRY( $currency_from ); 

Parameters (1)

0. $currency_from
The currency from.

Usage

  1. if ( !function_exists( 'alg_tcmb_get_exchange_rate_TRY' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'booster-for-woocommerce/includes/functions/wcj-exchange-rates-functions.php'; 
  3.  
  4. // The currency from. 
  5. $currency_from = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = alg_tcmb_get_exchange_rate_TRY($currency_from); 
  9.  

Defined (1)

The function is defined in the following location(s).

/includes/functions/wcj-exchange-rates-functions.php  
  1. function alg_tcmb_get_exchange_rate_TRY( $currency_from ) { 
  2. if ( 'TRY' === $currency_from ) { 
  3. return 1; 
  4. $xml = simplexml_load_file( 'http://www.tcmb.gov.tr/kurlar/today.xml' ); 
  5. if ( isset( $xml->Currency ) ) { 
  6. foreach ( $xml->Currency as $the_rate ) { 
  7. $attributes = $the_rate->attributes(); 
  8. if ( isset( $attributes['CurrencyCode'] ) ) { 
  9. $currency_code = (string) $attributes['CurrencyCode']; 
  10. if ( $currency_code === $currency_from ) { 
  11. // Possible values: ForexSelling, ForexBuying, BanknoteSelling, BanknoteBuying. Not used: CrossRateUSD, CrossRateOther. 
  12. if ( '' != ( $property_to_check = apply_filters( 'wcj_currency_exchange_rates_tcmb_property_to_check', '' ) ) ) { 
  13. if ( isset( $the_rate->{$property_to_check} ) ) { 
  14. $rate = (float) $the_rate->{$property_to_check}; 
  15. } else { 
  16. continue; 
  17. } else { 
  18. if ( isset( $the_rate->ForexSelling ) ) { 
  19. $rate = (float) $the_rate->ForexSelling; 
  20. } elseif ( isset( $the_rate->ForexBuying ) ) { 
  21. $rate = (float) $the_rate->ForexBuying; 
  22. } elseif ( isset( $the_rate->BanknoteSelling ) ) { 
  23. $rate = (float) $the_rate->BanknoteSelling; 
  24. } elseif ( isset( $the_rate->BanknoteBuying ) ) { 
  25. $rate = (float) $the_rate->BanknoteBuying; 
  26. } else { 
  27. continue; 
  28. $unit = ( isset( $the_rate->Unit ) ) ? (float) $the_rate->Unit : 1; 
  29. return ( $rate / $unit ); 
  30. return false;