public function MailchimpEcommerceHelper::getCurrencyCodes in Mailchimp E-Commerce 8
Returns currency codes from the xml file.
This is used if Drupal Commerce is not available.
Return value
array Array of currency codes.
File
- src/
MailchimpEcommerceHelper.php, line 129
Class
- MailchimpEcommerceHelper
- Class MailchimpEcommerceHelper.
Namespace
Drupal\mailchimp_ecommerceCode
public function getCurrencyCodes() {
$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;
}