本文整理汇总了PHP中Country::getIdByName方法的典型用法代码示例。如果您正苦于以下问题:PHP Country::getIdByName方法的具体用法?PHP Country::getIdByName怎么用?PHP Country::getIdByName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Country
的用法示例。
在下文中一共展示了Country::getIdByName方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addressImport
public function addressImport()
{
$this->receiveTab();
$defaultLanguageId = (int) Configuration::get('PS_LANG_DEFAULT');
$handle = $this->openCsvFile();
self::setLocale();
for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, Tools::getValue('separator')); $current_line++) {
if (Tools::getValue('convert')) {
$line = $this->utf8_encode_array($line);
}
$info = self::getMaskedRow($line);
self::setDefaultValues($info);
$address = new Address();
self::array_walk($info, array('AdminImport', 'fillInfo'), $address);
if (isset($address->country) and is_numeric($address->country)) {
if (Country::getNameById(Configuration::get('PS_LANG_DEFAULT'), (int) $address->country)) {
$address->id_country = (int) $address->country;
}
} elseif (isset($address->country) and is_string($address->country) and !empty($address->country)) {
if ($id_country = Country::getIdByName(NULL, $address->country)) {
$address->id_country = (int) $id_country;
} else {
$country = new Country();
$country->active = 1;
$country->name = self::createMultiLangField($address->country);
$country->id_zone = 0;
// Default zone for country to create
$country->iso_code = strtoupper(substr($address->country, 0, 2));
// Default iso for country to create
$country->contains_states = 0;
// Default value for country to create
$langFieldError = $country->validateFieldsLang(UNFRIENDLY_ERROR, true);
if (($fieldError = $country->validateFields(UNFRIENDLY_ERROR, true)) === true and ($langFieldError = $country->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true and $country->add()) {
$address->id_country = (int) $country->id;
} else {
$this->_errors[] = $country->name[$defaultLanguageId] . ' ' . Tools::displayError('Cannot be saved');
$this->_errors[] = ($fieldError !== true ? $fieldError : '') . ($langFieldError !== true ? $langFieldError : '') . mysql_error();
}
}
}
if (isset($address->state) and is_numeric($address->state)) {
if (State::getNameById((int) $address->state)) {
$address->id_state = (int) $address->state;
}
} elseif (isset($address->state) and is_string($address->state) and !empty($address->state)) {
if ($id_state = State::getIdByName($address->state)) {
$address->id_state = (int) $id_state;
} else {
$state = new State();
$state->active = 1;
$state->name = $address->state;
$state->id_country = isset($country->id) ? (int) $country->id : 0;
$state->id_zone = 0;
// Default zone for state to create
$state->iso_code = strtoupper(substr($address->state, 0, 2));
// Default iso for state to create
$state->tax_behavior = 0;
if (($fieldError = $state->validateFields(UNFRIENDLY_ERROR, true)) === true and ($langFieldError = $state->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true and $state->add()) {
$address->id_state = (int) $state->id;
} else {
$this->_errors[] = $state->name . ' ' . Tools::displayError('Cannot be saved');
$this->_errors[] = ($fieldError !== true ? $fieldError : '') . ($langFieldError !== true ? $langFieldError : '') . mysql_error();
}
}
}
if (isset($address->customer_email) and !empty($address->customer_email)) {
if (Validate::isEmail($address->customer_email)) {
$customer = Customer::customerExists($address->customer_email, true);
if ($customer) {
$address->id_customer = (int) $customer;
} else {
$this->_errors[] = mysql_error() . ' ' . $address->customer_email . ' ' . Tools::displayError('does not exist in database') . ' ' . (isset($info['id']) ? ' (ID ' . $info['id'] . ')' : '') . ' ' . Tools::displayError('Cannot be saved');
}
} else {
$this->_errors[] = '"' . $address->customer_email . '" :' . Tools::displayError('Is not a valid Email');
}
}
if (isset($address->manufacturer) and is_numeric($address->manufacturer) and Manufacturer::manufacturerExists((int) $address->manufacturer)) {
$address->id_manufacturer = (int) $address->manufacturer;
} elseif (isset($address->manufacturer) and is_string($address->manufacturer) and !empty($address->manufacturer)) {
$manufacturer = new Manufacturer();
$manufacturer->name = $address->manufacturer;
if (($fieldError = $manufacturer->validateFields(UNFRIENDLY_ERROR, true)) === true and ($langFieldError = $manufacturer->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true and $manufacturer->add()) {
$address->id_manufacturer = (int) $manufacturer->id;
} else {
$this->_errors[] = mysql_error() . ' ' . $manufacturer->name . (isset($manufacturer->id) ? ' (' . $manufacturer->id . ')' : '') . ' ' . Tools::displayError('Cannot be saved');
$this->_errors[] = ($fieldError !== true ? $fieldError : '') . ($langFieldError !== true ? $langFieldError : '') . mysql_error();
}
}
if (isset($address->supplier) and is_numeric($address->supplier) and Supplier::supplierExists((int) $address->supplier)) {
$address->id_supplier = (int) $address->supplier;
} elseif (isset($address->supplier) and is_string($address->supplier) and !empty($address->supplier)) {
$supplier = new Supplier();
$supplier->name = $address->supplier;
if (($fieldError = $supplier->validateFields(UNFRIENDLY_ERROR, true)) === true and ($langFieldError = $supplier->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true and $supplier->add()) {
$address->id_supplier = (int) $supplier->id;
} else {
$this->_errors[] = mysql_error() . ' ' . $supplier->name . (isset($supplier->id) ? ' (' . $supplier->id . ')' : '') . ' ' . Tools::displayError('Cannot be saved');
$this->_errors[] = ($fieldError !== true ? $fieldError : '') . ($langFieldError !== true ? $langFieldError : '') . mysql_error();
}
//.........这里部分代码省略.........
示例2: isSameAddress
public function isSameAddress($idAddress, $idCart, $idCustomer)
{
$return = Db::getInstance()->getRow('SELECT * FROM ' . _DB_PREFIX_ . 'socolissimo_delivery_info WHERE id_cart =\'' . (int) $idCart . '\' AND id_customer =\'' . (int) $idCustomer . '\'');
$psAddress = new Address((int) $idAddress);
$newAddress = new Address();
if ($this->upper($psAddress->lastname) != $this->upper($return['prname']) || $this->upper($psAddress->firstname) != $this->upper($return['prfirstname']) || $this->upper($psAddress->address1) != $this->upper($return['pradress3']) || $this->upper($psAddress->address2) != $this->upper($return['pradress2']) || $this->upper($psAddress->postcode) != $this->upper($return['przipcode']) || $this->upper($psAddress->city) != $this->upper($return['prtown']) || str_replace(array(' ', '.', '-', ',', ';', '+', '/', '\\', '+', '(', ')'), '', $psAddress->phone_mobile) != $return['cephonenumber']) {
$newAddress->id_customer = (int) $idCustomer;
$newAddress->lastname = substr($return['prname'], 0, 32);
$newAddress->firstname = substr($return['prfirstname'], 0, 32);
$newAddress->postcode = $return['przipcode'];
$newAddress->city = $return['prtown'];
$newAddress->id_country = Country::getIdByName(null, 'france');
$newAddress->alias = 'So Colissimo - ' . date('d-m-Y');
if (!in_array($return['delivery_mode'], array('DOM', 'RDV'))) {
$newAddress->active = 1;
$newAddress->deleted = 1;
$newAddress->address1 = $return['pradress1'];
$newAddress->add();
} else {
$newAddress->address1 = $return['pradress3'];
isset($return['pradress2']) ? $newAddress->address2 = $return['pradress2'] : ($newAddress->address2 = '');
isset($return['pradress1']) ? $newAddress->other .= $return['pradress1'] : ($newAddress->other = '');
isset($return['pradress4']) ? $newAddress->other .= ' | ' . $return['pradress4'] : ($newAddress->other = '');
$newAddress->postcode = $return['przipcode'];
$newAddress->city = $return['prtown'];
$newAddress->id_country = Country::getIdByName(null, 'france');
$newAddress->alias = 'So Colissimo - ' . date('d-m-Y');
$newAddress->add();
}
return (int) $newAddress->id;
} else {
return (int) $psAddress->id;
}
}
示例3: addAddresseInBDD
/**
* Add addresses
* @param $order_id
* @param $order_infos
* @param $type
* @param $id_customer
* @return mixed
*/
private function addAddresseInBDD($order_id, $neteven_address, $type, $id_customer)
{
$id_country = $this->getValue('id_country_default');
if (!($id_country = Country::getIdByName(2, $neteven_address->Country))) {
Toolbox::addLogLine(self::getL('Problem with id_country on address') . ' ' . $type . ' ' . self::getL('NetEven Order Id') . ' ' . $order_id);
}
$country = Db::getInstance()->getRow('
SELECT c.`id_country`
FROM `' . _DB_PREFIX_ . 'country` c
INNER JOIN `' . _DB_PREFIX_ . 'country_lang` cl ON (c.`id_country` = cl.`id_country`)
WHERE LOWER(c.`iso_code`) = "' . pSQL(strtolower($neteven_address->Country)) . '"
OR LOWER(cl.`name`) = "' . pSQL(strtolower($neteven_address->Country)) . '"
GROUP BY c.`id_country`
');
if (!empty($country['id_country'])) {
$id_country = $country['id_country'];
}
if ($id_address = Toolbox::existAddress($neteven_address, $id_country, $id_customer)) {
Toolbox::addLogLine(self::getL('Get existing address for NetEven Order Id') . ' ' . $order_id);
} else {
Toolbox::addLogLine(self::getL('Creation of address of NetEven order Id') . ' ' . $order_id);
$date_now = date('Y-m-d H:i:s');
$new_address = new Address();
$new_address->alias = 'Address';
$new_address->lastname = !empty($neteven_address->LastName) ? substr(Toolbox::stringFilter($neteven_address->LastName), 0, 32) : ' ';
$new_address->firstname = !empty($neteven_address->FirstName) ? substr(Toolbox::stringFilter($neteven_address->FirstName), 0, 32) : ' ';
$new_address->address1 = !empty($neteven_address->Address1) ? Toolbox::stringWithNumericFilter($neteven_address->Address1) : ' ';
$new_address->address2 = Toolbox::stringWithNumericFilter($neteven_address->Address2);
$new_address->postcode = Toolbox::numericFilter($neteven_address->PostalCode);
$new_address->city = !empty($neteven_address->CityName) ? Toolbox::stringFilter($neteven_address->CityName) : ' ';
$new_address->phone = substr(Toolbox::numericFilter($neteven_address->Phone), 0, 16);
$new_address->phone_mobile = substr(Toolbox::numericFilter($neteven_address->Mobile), 0, 16);
$new_address->id_country = $id_country;
$new_address->id_customer = $id_customer;
$new_address->date_add = $date_now;
$new_address->date_upd = $date_now;
if (!empty($neteven_address->Company)) {
$new_address->company = $neteven_address->Company;
}
if (!$new_address->add()) {
Toolbox::addLogLine(self::getL('Failed for creation of address of NetEven order Id') . ' ' . $order_id);
} else {
$id_address = $new_address->id;
}
}
return $id_address;
}
示例4: storeContactImportOne
public function storeContactImportOne($info, $shop_is_feature_active, $regenerate, $force_ids, $validateOnly = false)
{
AdminImportController::setDefaultValues($info);
if ($force_ids && isset($info['id']) && (int) $info['id']) {
$store = new Store((int) $info['id']);
} else {
if (array_key_exists('id', $info) && (int) $info['id'] && Store::existsInDatabase((int) $info['id'], 'store')) {
$store = new Store((int) $info['id']);
} else {
$store = new Store();
}
}
AdminImportController::arrayWalk($info, array('AdminImportController', 'fillInfo'), $store);
if (isset($store->image) && !empty($store->image)) {
if (!AdminImportController::copyImg($store->id, null, $store->image, 'stores', !$regenerate)) {
$this->warnings[] = $store->image . ' ' . $this->trans('cannot be copied.', array(), 'Admin.Parameters.Notification');
}
}
if (isset($store->hours) && is_array($store->hours)) {
$store->hours = serialize($store->hours);
}
if (isset($store->country) && is_numeric($store->country)) {
if (Country::getNameById(Configuration::get('PS_LANG_DEFAULT'), (int) $store->country)) {
$store->id_country = (int) $store->country;
}
} elseif (isset($store->country) && is_string($store->country) && !empty($store->country)) {
if ($id_country = Country::getIdByName(null, $store->country)) {
$store->id_country = (int) $id_country;
} else {
$country = new Country();
$country->active = 1;
$country->name = AdminImportController::createMultiLangField($store->country);
$country->id_zone = 0;
// Default zone for country to create
$country->iso_code = Tools::strtoupper(Tools::substr($store->country, 0, 2));
// Default iso for country to create
$country->contains_states = 0;
// Default value for country to create
$lang_field_error = $country->validateFieldsLang(UNFRIENDLY_ERROR, true);
if (($field_error = $country->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $country->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true && !$validateOnly && $country->add()) {
$store->id_country = (int) $country->id;
} else {
if (!$validateOnly) {
$default_language_id = (int) Configuration::get('PS_LANG_DEFAULT');
$this->errors[] = sprintf($this->trans('%s cannot be saved', array(), 'Admin.Parameters.Notification'), $country->name[$default_language_id]);
}
if ($field_error !== true || isset($lang_field_error) && $lang_field_error !== true) {
$this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '') . Db::getInstance()->getMsgError();
}
}
}
}
if (isset($store->state) && is_numeric($store->state)) {
if (State::getNameById((int) $store->state)) {
$store->id_state = (int) $store->state;
}
} elseif (isset($store->state) && is_string($store->state) && !empty($store->state)) {
if ($id_state = State::getIdByName($store->state)) {
$store->id_state = (int) $id_state;
} else {
$state = new State();
$state->active = 1;
$state->name = $store->state;
$state->id_country = isset($country->id) ? (int) $country->id : 0;
$state->id_zone = 0;
// Default zone for state to create
$state->iso_code = Tools::strtoupper(Tools::substr($store->state, 0, 2));
// Default iso for state to create
$state->tax_behavior = 0;
if (($field_error = $state->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $state->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true && !$validateOnly && $state->add()) {
$store->id_state = (int) $state->id;
} else {
if (!$validateOnly) {
$this->errors[] = sprintf($this->trans('%s cannot be saved', array(), 'Admin.Parameters.Notification'), $state->name);
}
if ($field_error !== true || isset($lang_field_error) && $lang_field_error !== true) {
$this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '') . Db::getInstance()->getMsgError();
}
}
}
}
$res = false;
if (($field_error = $store->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $store->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true) {
if ($store->id && $store->storeExists($store->id)) {
$res = $validateOnly ? $validateOnly : $store->update();
}
$store->force_id = (bool) $force_ids;
if (!$res) {
$res = $validateOnly ? $validateOnly : $store->add();
}
if (!$res) {
$this->errors[] = Db::getInstance()->getMsgError() . ' ' . sprintf($this->trans('%1$s (ID: %2$s) cannot be saved', array(), 'Admin.Parameters.Notification'), $info['name'], isset($info['id']) ? $info['id'] : 'null');
}
} else {
$this->errors[] = $this->l('Store is invalid') . ' (' . $store->name . ')';
$this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '');
}
}
示例5: addressImport
public function addressImport()
{
$this->receiveTab();
$default_language_id = (int) Configuration::get('PS_LANG_DEFAULT');
$handle = $this->openCsvFile();
AdminImportController::setLocale();
for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator); $current_line++) {
if (Tools::getValue('convert')) {
$line = $this->utf8EncodeArray($line);
}
$info = AdminImportController::getMaskedRow($line);
AdminImportController::setDefaultValues($info);
$address = new Address();
AdminImportController::arrayWalk($info, array('AdminImportController', 'fillInfo'), $address);
if (isset($address->country) && is_numeric($address->country)) {
if (Country::getNameById(Configuration::get('PS_LANG_DEFAULT'), (int) $address->country)) {
$address->id_country = (int) $address->country;
}
} elseif (isset($address->country) && is_string($address->country) && !empty($address->country)) {
if ($id_country = Country::getIdByName(null, $address->country)) {
$address->id_country = (int) $id_country;
} else {
$country = new Country();
$country->active = 1;
$country->name = AdminImportController::createMultiLangField($address->country);
$country->id_zone = 0;
// Default zone for country to create
$country->iso_code = Tools::strtoupper(Tools::substr($address->country, 0, 2));
// Default iso for country to create
$country->contains_states = 0;
// Default value for country to create
$lang_field_error = $country->validateFieldsLang(UNFRIENDLY_ERROR, true);
if (($field_error = $country->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $country->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true && $country->add()) {
$address->id_country = (int) $country->id;
} else {
$this->errors[] = sprintf(Tools::displayError('%s cannot be saved'), $country->name[$default_language_id]);
$this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '') . Db::getInstance()->getMsgError();
}
}
}
if (isset($address->state) && is_numeric($address->state)) {
if (State::getNameById((int) $address->state)) {
$address->id_state = (int) $address->state;
}
} elseif (isset($address->state) && is_string($address->state) && !empty($address->state)) {
if ($id_state = State::getIdByName($address->state)) {
$address->id_state = (int) $id_state;
} else {
$state = new State();
$state->active = 1;
$state->name = $address->state;
$state->id_country = isset($country->id) ? (int) $country->id : 0;
$state->id_zone = 0;
// Default zone for state to create
$state->iso_code = Tools::strtoupper(Tools::substr($address->state, 0, 2));
// Default iso for state to create
$state->tax_behavior = 0;
if (($field_error = $state->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $state->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true && $state->add()) {
$address->id_state = (int) $state->id;
} else {
$this->errors[] = sprintf(Tools::displayError('%s cannot be saved'), $state->name);
$this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '') . Db::getInstance()->getMsgError();
}
}
}
if (isset($address->customer_email) && !empty($address->customer_email)) {
if (Validate::isEmail($address->customer_email)) {
// a customer could exists in different shop
$customer_list = Customer::getCustomersByEmail($address->customer_email);
if (count($customer_list) == 0) {
$this->errors[] = sprintf(Tools::displayError('%1$s does not exist in database %2$s (ID: %3$s), and therefore cannot be saved.'), Db::getInstance()->getMsgError(), $address->customer_email, isset($info['id']) && !empty($info['id']) ? $info['id'] : 'null');
}
} else {
$this->errors[] = sprintf(Tools::displayError('"%s" is not a valid email address.'), $address->customer_email);
continue;
}
} elseif (isset($address->id_customer) && !empty($address->id_customer)) {
if (Customer::customerIdExistsStatic((int) $address->id_customer)) {
$customer = new Customer((int) $address->id_customer);
// a customer could exists in different shop
$customer_list = Customer::getCustomersByEmail($customer->email);
if (count($customer_list) == 0) {
$this->errors[] = sprintf(Tools::displayError('%1$s does not exist in database %2$s (ID: %3$s), and therefore cannot be saved.'), Db::getInstance()->getMsgError(), $customer->email, (int) $address->id_customer);
}
} else {
$this->errors[] = sprintf(Tools::displayError('The customer ID #%d does not exist in the database, and therefore cannot be saved.'), $address->id_customer);
}
} else {
$customer_list = array();
$address->id_customer = 0;
}
if (isset($address->manufacturer) && is_numeric($address->manufacturer) && Manufacturer::manufacturerExists((int) $address->manufacturer)) {
$address->id_manufacturer = (int) $address->manufacturer;
} elseif (isset($address->manufacturer) && is_string($address->manufacturer) && !empty($address->manufacturer)) {
$manufacturer = new Manufacturer();
$manufacturer->name = $address->manufacturer;
if (($field_error = $manufacturer->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $manufacturer->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true && $manufacturer->add()) {
$address->id_manufacturer = (int) $manufacturer->id;
} else {
$this->errors[] = Db::getInstance()->getMsgError() . ' ' . sprintf(Tools::displayError('%1$s (ID: %2$s) cannot be saved'), $manufacturer->name, isset($manufacturer->id) && !empty($manufacturer->id) ? $manufacturer->id : 'null');
//.........这里部分代码省略.........
示例6: defined
<?php
defined('DS') ? null : define('DS', DIRECTORY_SEPARATOR);
require_once dirname(__FILE__) . '../../config/config.inc.php';
require_once dirname(__FILE__) . '../../init.php';
$data = array();
$id_country = Country::getIdByName(1, Tools::getValue('country'));
$contain_state = Country::containsStates($id_country);
if ($contain_state) {
$states = State::getStatesByIdCountry($id_country);
$data['states'] = $states;
}
$data['id_country'] = $id_country;
$data['contain_state'] = $contain_state;
echo json_encode($data);
示例7: getOrderDetails
private function getOrderDetails($id_order)
{
global $cookie;
$confs = Configuration::getMultiple(array('EMC_LOGIN', 'PS_SHOP_NAME', 'EMC_GENDER', 'EMC_FIRST_NAME', 'EMC_LAST_NAME', 'EMC_ADDRESS', 'EMC_ZIP_CODE', 'EMC_CITY', 'EMC_COUNTRY', 'EMC_PHONE', 'EMC_EMAIL', 'EMC_EMAILS'));
$orderDetails = array();
$order = new Order((int) $id_order);
$customer = new Customer((int) $order->id_customer);
$adresseDelivery = new Address((int) $order->id_address_delivery);
$genderTab = array(1 => 'M.', 2 => 'Mme', 9 => '');
$orderDetails['url_suivi'] = Tools::getProtocol() . htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8') . __PS_BASE_URI__ . 'modules/envoimoinscher/tracking.php?token=' . $customer->secure_key;
$orderDetails['infoexterne'] = str_replace('.', '_', str_replace('www.', '', $_SERVER['HTTP_HOST'])) . '_' . (int) $id_order;
$orderDetails['packaging'] = Tools::getValue('packaging_' . (int) $id_order);
$orderDetails['type_objet'] = Tools::getValue('type_objet_' . (int) $id_order);
$orderDetails['envoi_emailsconf'] = (int) $confs['EMC_EMAILS'];
//products infos
$productsDetails = $order->getProductsDetail();
$tabDetails = array();
foreach ($productsDetails as $details) {
$features = self::getFeatures((int) $details['product_id']);
$tabDetailsProduct = array();
$tabDetailsProduct['id'] = (int) $details['product_id'];
$tabDetailsProduct['nb'] = (int) $details['product_quantity'];
$tabDetailsProduct['poids'] = (double) $details['product_weight'];
$tabDetailsProduct['description'] = htmlspecialchars($details['product_name'], ENT_COMPAT, 'UTF-8');
foreach ($features as $key => $value) {
$tabDetailsProduct[$key] = $value;
}
$tabDetails[] = $tabDetailsProduct;
}
$orderDetails['products'] = $tabDetails;
//sending infos
$orderExpediteur['civilite'] = htmlspecialchars($genderTab[$confs['EMC_GENDER']], ENT_COMPAT, 'UTF-8');
$orderExpediteur['collecte_type'] = 'entreprise';
$orderExpediteur['societe'] = htmlspecialchars($confs['PS_SHOP_NAME'], ENT_COMPAT, 'UTF-8');
$orderExpediteur['nom'] = htmlspecialchars($confs['EMC_LAST_NAME'], ENT_COMPAT, 'UTF-8');
$orderExpediteur['prenom'] = htmlspecialchars($confs['EMC_FIRST_NAME'], ENT_COMPAT, 'UTF-8');
$orderExpediteur['adresse'] = htmlspecialchars($confs['EMC_ADDRESS'], ENT_COMPAT, 'UTF-8');
$orderExpediteur['codepostal'] = htmlspecialchars($confs['EMC_ZIP_CODE'], ENT_COMPAT, 'UTF-8');
$orderExpediteur['ville'] = htmlspecialchars($confs['EMC_CITY'], ENT_COMPAT, 'UTF-8');
$orderExpediteur['pz_id'] = htmlspecialchars($confs['EMC_COUNTRY'], ENT_COMPAT, 'UTF-8');
$orderExpediteur['tel'] = htmlspecialchars($confs['EMC_PHONE'], ENT_COMPAT, 'UTF-8');
$orderExpediteur['email'] = htmlspecialchars($confs['EMC_EMAIL'], ENT_COMPAT, 'UTF-8');
$orderDetails['expediteur'] = $orderExpediteur;
//delivery infos
$orderDelivery['civilite'] = $genderTab[(int) $customer->id_gender];
if (isset($adresseDelivery->company)) {
$orderDelivery['collecte_type'] = 'particulier';
}
$orderDelivery['societe'] = htmlspecialchars($adresseDelivery->company, ENT_COMPAT, 'UTF-8');
$orderDelivery['prenom'] = htmlspecialchars($adresseDelivery->firstname, ENT_COMPAT, 'UTF-8');
$orderDelivery['nom'] = htmlspecialchars($adresseDelivery->lastname, ENT_COMPAT, 'UTF-8');
$orderDelivery['adresse'] = htmlspecialchars($adresseDelivery->address1, ENT_COMPAT, 'UTF-8');
$orderDelivery['codepostal'] = htmlspecialchars($adresseDelivery->postcode, ENT_COMPAT, 'UTF-8');
$orderDelivery['ville'] = htmlspecialchars($adresseDelivery->city, ENT_COMPAT, 'UTF-8');
$orderDelivery['pz_id'] = Country::getIsoById(Country::getIdByName((int) $cookie->id_lang, $adresseDelivery->country));
if (isset($adresseDelivery->phone)) {
$orderDelivery['tel'] = htmlspecialchars($adresseDelivery->phone, ENT_COMPAT, 'UTF-8');
} else {
$orderDelivery['tel'] = htmlspecialchars($adresseDelivery->phone_mobile, ENT_COMPAT, 'UTF-8');
}
$orderDelivery['email'] = htmlspecialchars($customer->email, ENT_COMPAT, 'UTF-8');
$orderDetails['destinataire'] = $orderDelivery;
//d($orderDetails);
return $orderDetails;
}
示例8: _getColissimoShippingAddress
private function _getColissimoShippingAddress($cart, $psAddress, $idCustomer)
{
// So Colissimo not installed
if (!Configuration::get('SOCOLISSIMO_CARRIER_ID')) {
return false;
}
// So Colissimo is not selected as shipping method
if ($cart->id_carrier != Configuration::get('SOCOLISSIMO_CARRIER_ID')) {
return false;
}
// Get address saved by So Colissimo
$return = Db::getInstance()->getRow('SELECT * FROM ' . _DB_PREFIX_ . 'socolissimo_delivery_info WHERE id_cart =\'' . (int) $cart->id . '\' AND id_customer =\'' . (int) $idCustomer . '\'');
$newAddress = new Address();
if (strtoupper($psAddress->lastname) != strtoupper($return['prname']) || strtoupper($psAddress->firstname) != strtoupper($return['prfirstname']) || strtoupper($psAddress->address1) != strtoupper($return['pradress3']) || strtoupper($psAddress->address2) != strtoupper($return['pradress2']) || strtoupper($psAddress->postcode) != strtoupper($return['przipcode']) || strtoupper($psAddress->city) != strtoupper($return['prtown']) || str_replace(array(' ', '.', '-', ',', ';', '+', '/', '\\', '+', '(', ')'), '', $psAddress->phone_mobile) != $return['cephonenumber']) {
// Address is modified in So Colissimo page : use it as shipping address
$newAddress->lastname = substr($return['prname'], 0, 32);
$newAddress->firstname = substr($return['prfirstname'], 0, 32);
$newAddress->postcode = $return['przipcode'];
$newAddress->city = $return['prtown'];
$newAddress->id_country = Country::getIdByName(null, 'france');
if (!in_array($return['delivery_mode'], array('DOM', 'RDV'))) {
$newAddress->address1 = $return['pradress1'];
$newAddress->address1 .= isset($return['pradress2']) ? ' ' . $return['pradress2'] : '';
$newAddress->address1 .= isset($return['pradress3']) ? ' ' . $return['pradress3'] : '';
$newAddress->address1 .= isset($return['pradress4']) ? ' ' . $return['pradress4'] : '';
} else {
$newAddress->address1 = $return['pradress3'];
$newAddress->address2 = isset($return['pradress4']) ? $return['pradress4'] : '';
$newAddress->other = isset($return['pradress1']) ? $return['pradress1'] : '';
$newAddress->other .= isset($return['pradress2']) ? ' ' . $return['pradress2'] : '';
}
// Return the So Colissimo updated
return $newAddress;
} else {
// Use initial address
return false;
}
}