private function _postValidationShipping() { $collect = Tools::getValue('tnt_carrier_shipping_collect') == 'on' ? 1 : 0; $company = pSQL(Tools::getValue('tnt_carrier_shipping_company')); $pex = pSQL(Tools::getValue('tnt_carrier_shipping_pex')); $lname = pSQL(Tools::getValue('tnt_carrier_shipping_last_name')); $fname = pSQL(Tools::getValue('tnt_carrier_shipping_first_name')); $address1 = pSQL(Tools::getValue('tnt_carrier_shipping_address1')); $address2 = pSQL(Tools::getValue('tnt_carrier_shipping_address2')); $postal_code = pSQL(Tools::getValue('tnt_carrier_shipping_postal_code')); $city = pSQL(Tools::getValue('tnt_carrier_shipping_city')); $email = pSQL(Tools::getValue('tnt_carrier_shipping_email')); $phone = pSQL(Tools::getValue('tnt_carrier_shipping_phone')); $closing = pSQL(Tools::getValue('tnt_carrier_shipping_closing')); $delivery = pSQL(Tools::getValue('tnt_carrier_shipping_delivery')); $print = pSQL(Tools::getValue('tnt_carrier_print_sticker')); if (!Configuration::get('TNT_CARRIER_LOGIN') || !Configuration::get('TNT_CARRIER_PASSWORD') || !Configuration::get('TNT_CARRIER_NUMBER_ACCOUNT')) { $this->_postErrors[] = $this->l('You need a TNT account to complete your shipping address'); } /*if (!$collect && $pex == '') $this->_postErrors[] = $this->l('The pex code is missing');*/ if ($collect && $company == '') { $this->_postErrors[] = $this->l('Company name is missing'); } if ($collect && !$lname) { $this->_postErrors[] = $this->l('Contact last name is missing'); } if ($collect && !$fname) { $this->_postErrors[] = $this->l('Contact first name is missing'); } if (!$address1) { $this->_postErrors[] = $this->l('Address is missing'); } if (isset($address2) && strlen($address2) >= 32) { $this->_postErrors[] = $this->l('Address line 2 must be under 32 characters'); } if (!$postal_code) { $this->_postErrors[] = $this->l('Postal code is missing'); } if (!$email) { $this->_postErrors[] = $this->l('Contact email address is missing'); } if (!$phone) { $this->_postErrors[] = $this->l('Contact phone number is missing'); } if ($collect && $closing == '') { $this->_postErrors[] = $this->l('Company closing time is missing'); } if (Configuration::get('TNT_CARRIER_LOGIN') && Configuration::get('TNT_CARRIER_PASSWORD') && Configuration::get('TNT_CARRIER_NUMBER_ACCOUNT')) { if (strpos($city, 'PARIS') === 0 || strpos($city, 'MARSEILLE') === 0 || strpos($city, 'LYON') === 0) { $department = substr($postal_code, 0, 2); $code = substr($city, -2); $postal_code = $department . '0' . $code; } $tntWebService = new TntWebService(); try { $verif = $tntWebService->verifCity($postal_code, $city); } catch (SoapFault $e) { $this->_postErrors[] = $this->l('Verify your authentication'); } if (!isset($verif) || !$verif) { $this->_postErrors[] = $this->l('The city is not compatible with the postal code'); } } Configuration::updateValue('TNT_CARRIER_SHIPPING_COLLECT', $collect); Configuration::updateValue('TNT_CARRIER_SHIPPING_COMPANY', $company); Configuration::updateValue('TNT_CARRIER_SHIPPING_LASTNAME', $lname); Configuration::updateValue('TNT_CARRIER_SHIPPING_FIRSTNAME', $fname); Configuration::updateValue('TNT_CARRIER_SHIPPING_ADDRESS1', $address1); Configuration::updateValue('TNT_CARRIER_SHIPPING_ADDRESS2', $address2); Configuration::updateValue('TNT_CARRIER_SHIPPING_ZIPCODE', $postal_code); Configuration::updateValue('TNT_CARRIER_SHIPPING_CITY', $city); Configuration::updateValue('TNT_CARRIER_SHIPPING_EMAIL', $email); Configuration::updateValue('TNT_CARRIER_SHIPPING_PHONE', $phone); Configuration::updateValue('TNT_CARRIER_SHIPPING_CLOSING', $closing); Configuration::updateValue('TNT_CARRIER_SHIPPING_DELIVERY', $delivery); Configuration::updateValue('TNT_CARRIER_SHIPPING_PEX', $pex); Configuration::updateValue('TNT_CARRIER_PRINT_STICKER', $print); }