You are here

public function CommerceSmartImporerService::checkCurrencyValidity in Commerce Smart Importer 8

Checks if currency is valid and returns formated.

1 call to CommerceSmartImporerService::checkCurrencyValidity()
CommerceSmartImporerService::variationCurrencyValidityPass in src/Plugin/CommerceSmartImporerService.php
Checks if currency is valid and reformats price.

File

src/Plugin/CommerceSmartImporerService.php, line 886
Main Commerce Smart Importer Service.

Class

CommerceSmartImporerService
This is main Commerce Smart Importer Service.

Namespace

Drupal\commerce_smart_importer\Plugin

Code

public function checkCurrencyValidity($code) {

  /* @var \Drupal\commerce_price\Entity\Currency $currecies */
  $currecies = Currency::loadMultiple();
  foreach ($currecies as $currency) {
    if ($code == $currency
      ->getCurrencyCode() || strtolower($code) == strtolower($currency
      ->getName()) || $code == $currency
      ->getNumericCode() || $code == $currency
      ->getSymbol()) {
      return $currency
        ->getCurrencyCode();
    }
  }
  return FALSE;
}