You are here

function mailchimp_ecommerce_get_currency_codes in Mailchimp E-Commerce 7

Same name and namespace in other branches
  1. 8 mailchimp_ecommerce.module \mailchimp_ecommerce_get_currency_codes()

Returns currency codes from the xml file.

This is used if Drupal Commerce is not available.

Return value

array Array of currency codes.

1 call to mailchimp_ecommerce_get_currency_codes()
mailchimp_ecommerce_admin_settings in includes/mailchimp_ecommerce.admin.inc
The Mailchimp eCommerce settings form.

File

./mailchimp_ecommerce.module, line 1261
Mailchimp eCommerce core functionality.

Code

function mailchimp_ecommerce_get_currency_codes() {
  $currencyfile = drupal_get_path('module', 'mailchimp_ecommerce') . '/' . 'currency-codes-iso4217.xml';
  $currencydata = simplexml_load_file($currencyfile);
  $json_string = json_encode($currencydata);
  $result_array = json_decode($json_string, TRUE);
  $currencycodes = [];
  foreach ($result_array['CcyTbl']['CcyNtry'] as $item) {
    if (!empty($item['Ccy'])) {
      $currencycodes[$item['Ccy']] = $item['CcyNm'] . ' (' . $item['Ccy'] . ')';
    }
  }
  return $currencycodes;
}