bebeboutik/modules/soflexibilite/functions/getCustomerAddress.php
Marion Muszynski ffbb3232b9 modif soflex
2016-05-09 17:43:57 +02:00

92 lines
3.7 KiB
PHP

<?php
/**
* NOTICE OF LICENSE
*
* This source file is subject to a commercial license from Common-Services Co., Ltd.
* Use, copy, modification or distribution of this source file without written
* license agreement from the SARL SMC is strictly forbidden.
* In order to obtain a license, please contact us: contact@common-services.com
* ...........................................................................
* INFORMATION SUR LA LICENCE D'UTILISATION
*
* L'utilisation de ce fichier source est soumise a une licence commerciale
* concedee par la societe Common-Services Co., Ltd.
* Toute utilisation, reproduction, modification ou distribution du present
* fichier source sans contrat de licence ecrit de la part de la Common-Services Co. Ltd. est
* expressement interdite.
* Pour obtenir une licence, veuillez contacter Common-Services Co., Ltd. a l'adresse: contact@common-services.com
* ...........................................................................
*
* @package So Colissimo Flexibilite
* @author Alexandre D.
* @copyright Copyright (c) 2011-2015 Common Services Co Ltd - 90/25 Sukhumvit 81 - 10260 Bangkok - Thailand
* @license Commercial license
* Support by mail : support.soflexibilite@common-services.com
*/
require_once(dirname(__FILE__).'/../../../config/config.inc.php');
require_once(dirname(__FILE__).'/../../../init.php');
require_once(dirname(__FILE__).'/../soflexibilite.php');
class InitSoflexibiliteEnv extends SoFlexibilite
{
public function initEnvSoflexibilite()
{
ob_start();
$this->parser_url = $this->url.'/functions/parser.php';
$this->checkPointSelectedOPC_url = $this->url.'/functions/checkPointSelectedOPC.php';
if ($this->ps15x)
{
$customerAddresses = $this->context->customer->getAddresses((int)$this->context->cookie->id_lang);
$id_delivery_address = (int)$this->context->cart->id_address_delivery;
}
else
{
$customerAddresses = Db::getInstance()->ExecuteS('SELECT * FROM '._DB_PREFIX_.'address WHERE id_customer='.(int)$this->context->cookie->id_customer);
$id_delivery_address = (int)$this->context->cart->id_address_delivery;
}
$html = '';
foreach ($customerAddresses as $address)
{
if ((int)$address['id_address'] === $id_delivery_address)
{
$html .= '<input type="hidden" id="sl-0-company" value="'.$address['company'].'">';
$html .= '<input type="hidden" id="sl-0-firstname" value="'.$address['firstname'].'">';
$html .= '<input type="hidden" id="sl-0-lastname" value="'.$address['lastname'].'">';
$html .= '<input type="hidden" id="sl-0-address1" value="'.$address['address1'].'">';
$html .= '<input type="hidden" id="sl-0-address2" value="'.$address['address2'].'">';
$html .= '<input type="hidden" id="sl-0-postcode" value="'.$address['postcode'].'">';
$html .= '<input type="hidden" id="sl-0-city" value="'.$address['city'].'">';
$html .= '<input type="hidden" id="sl-0-country" value="'.Country::getNameById($this->id_lang, $address['id_country']).'">';
$html .= '<input type="hidden" id="sl-0-mail" value="'.$this->context->customer->email.'">';
if (isset($address['phone_mobile']))
{
$tel = preg_replace('[^\x30-\x39]', '', $address['phone_mobile']);
$tel = Tools::substr($address['phone_mobile'], Tools::strlen($address['phone_mobile']) - 9);
$tel = sprintf('%010s', $tel);
if (Tools::substr($tel, 1, 1) == 6 || Tools::substr($tel, 1, 1) == 7 || Tools::substr($tel, 1, 1) == 4)
$html .= '<input type="hidden" id="sl-0-phone" value="'.$tel.'">';
}
}
}
$result = $html.ob_get_clean();
print ($result);
die;
}
}
$SoflexibiliteEnv = new InitSoflexibiliteEnv();
$SoflexibiliteEnv->initEnvSoflexibilite();