function isValid(&$vat) { $class = hikashop_get('class.zone'); $zone = $class->get(@$vat->address_country); if (empty($zone->zone_code_2) || !in_array($zone->zone_code_2, array('AT', 'BE', 'BG', 'CY', 'CZ', 'DK', 'EE', 'EL', 'DE', 'PT', 'GR', 'ES', 'FI', 'HR', 'HU', 'LU', 'MT', 'SI', 'FR', 'GB', 'IE', 'IT', 'LV', 'LT', 'NL', 'PL', 'SK', 'RO', 'SE'))) { return true; } if ($zone->zone_code_2 == 'ES' && !empty($vat->address_state)) { $statezone = $class->get(@$vat->address_state); if ($statezone->zone_code_3 == 'GC' || $statezone->zone_code_3 == 'TF') { return true; } } static $vat_check = null; if (!isset($vat_check)) { $config = hikashop_config(); $vat_check = (int) $config->get('vat_check', 2); } if ($zone->zone_code_2 == 'GR') { $zone->zone_code_2 = 'EL'; } switch ($vat_check) { case 1: case 2: if (is_object($vat)) { $vat_number =& $vat->address_vat; } else { $vat_number =& $vat; } $regex = $this->getRegex($vat_number); if ($regex === false) { if (is_object($vat) && !empty($vat->address_country)) { if (!empty($zone->zone_code_2)) { $vat_number = $zone->zone_code_2 . $vat_number; $regex = $this->getRegex($vat_number); } } if ($regex === false) { $app = JFactory::getApplication(); $this->message = JText::_('VAT_NOT_FOR_YOUR_COUNTRY'); if (@$_REQUEST['tmpl'] == 'component') { hikashop_display($this->message, 'error'); } else { $app->enqueueMessage($this->message); } return false; } } if (!$this->regexCheck($vat_number, $regex)) { return false; } $vat_number = strtoupper(str_replace(array(' ', '.', '-'), array('', '', ''), $vat_number)); $code = substr($vat_number, 0, 2); if ($code == 'GR') { $code = 'EL'; $vat_number = $code . substr($vat_number, 2); } if ($zone->zone_code_2 != $code) { $app = JFactory::getApplication(); $this->message = JTex::sprintf('WRONG_VAT_NUMBER_COUNTRY_CODE', $code, $zone->zone_code_2); if (@$_REQUEST['tmpl'] == 'component') { hikashop_display($this->message, 'error'); } else { $app->enqueueMessage($this->message); } return false; } if ($vat_check == 2) { return $this->onlineCheck($vat_number); } case 0: default: } return true; }