106 lines
3.5 KiB
PHP
106 lines
3.5 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');
|
|
if (version_compare(_PS_VERSION_, '1.5', '<')) {
|
|
require_once(dirname(__FILE__).'/../../../init.php');
|
|
}
|
|
require_once(_PS_MODULE_DIR_.'soflexibilite/soflexibilite.php');
|
|
require_once(_PS_MODULE_DIR_.'soflexibilite/classes/SoFlexibiliteDelivery.php');
|
|
|
|
|
|
class SoFlexibiliteSaveInfoCommande extends SoFlexibilite
|
|
{
|
|
|
|
public function save()
|
|
{
|
|
ob_start();
|
|
|
|
$id_cart = (int)Tools::getValue('cart');
|
|
|
|
$phone = null;
|
|
$info = null;
|
|
$status = true;
|
|
|
|
$update_required = false;
|
|
|
|
$soDelivery = new SoFlexibiliteDelivery();
|
|
$soDelivery->id_cart = (int)$id_cart;
|
|
$soDelivery->id_customer = (int)$this->context->customer->id;
|
|
$soDelivery->loadDelivery();
|
|
|
|
$phone = trim(Tools::getValue('phone'));
|
|
$info = trim(Tools::getValue('infoDelivery'));
|
|
$email = trim(Tools::getValue('email'));
|
|
$delivery_mode = Tools::strtoupper(trim(Tools::getValue('delivery_mode')));
|
|
|
|
if ($phone && $soDelivery->telephone != $phone) {
|
|
$soDelivery->telephone = pSQL(str_replace(' ', '', $phone));
|
|
$update_required = true;
|
|
}
|
|
|
|
if ($info && $soDelivery->informations != $info) {
|
|
$soDelivery->informations = pSQL($info);
|
|
$update_required = true;
|
|
}
|
|
|
|
if ($email && $soDelivery->email != $email) {
|
|
$soDelivery->email = pSQL($email);
|
|
$update_required = true;
|
|
}
|
|
|
|
if ($delivery_mode && $soDelivery->type != $delivery_mode) {
|
|
$soDelivery->type = pSQL($delivery_mode);
|
|
$update_required = true;
|
|
}
|
|
|
|
if ($update_required) {
|
|
$status = $soDelivery->saveDelivery() ? true : false;
|
|
}
|
|
|
|
$result = ob_get_clean();
|
|
|
|
if ($result) {
|
|
$output = $result;
|
|
} else {
|
|
$output = null;
|
|
}
|
|
|
|
$json = array(
|
|
'output' => $output,
|
|
'status' => $status,
|
|
'phone' => $phone,
|
|
'mail' => $email,
|
|
'info' => $info
|
|
);
|
|
die(Tools::jsonEncode($json));
|
|
}
|
|
}
|
|
|
|
|
|
$soflexibilite_saveinfocommande = new SoFlexibiliteSaveInfoCommande();
|
|
$soflexibilite_saveinfocommande->save();
|