private function CommerceSmartImporerService::variationCurrencyValidityPass in Commerce Smart Importer 8
Checks if currency is valid and reformats price.
1 call to CommerceSmartImporerService::variationCurrencyValidityPass()
- CommerceSmartImporerService::createNewProduct in src/
Plugin/ CommerceSmartImporerService.php - Creates product.
File
- src/
Plugin/ CommerceSmartImporerService.php, line 1465 - Main Commerce Smart Importer Service.
Class
- CommerceSmartImporerService
- This is main Commerce Smart Importer Service.
Namespace
Drupal\commerce_smart_importer\PluginCode
private function variationCurrencyValidityPass(&$variation, $field_definitions) {
$currency = '';
foreach ($field_definitions['variation'] as $field_definition) {
if ($field_definition['field_types'] == 'currency') {
$currency = $variation[$field_definition['index']];
break;
}
}
$currency = $this
->checkCurrencyValidity($currency);
if ($currency === FALSE) {
return FALSE;
}
foreach ($field_definitions['variation'] as $field_definition) {
if ($field_definition['field_types'] == 'commerce_price') {
if (isset($field_definition['index'])) {
if (strpos($variation[$field_definition['index']], $currency) === FALSE && $variation[$field_definition['index']] != '') {
$variation[$field_definition['index']] = $variation[$field_definition['index']] . ' ' . $currency;
}
}
}
}
return TRUE;
}