109 lines
3.9 KiB
PHP
109 lines
3.9 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
|
|
*/
|
|
|
|
ob_start();
|
|
|
|
require_once(dirname(__FILE__).'/../../../config/config.inc.php');
|
|
require_once(dirname(__FILE__).'/../../../init.php');
|
|
|
|
require_once(_PS_MODULE_DIR_.'soflexibilite/soflexibilite.php');
|
|
require_once(_PS_MODULE_DIR_.'soflexibilite/classes/SoFlexibiliteWebService.php');
|
|
|
|
$id_pickup = Tools::getValue('id_pickup');
|
|
$id_customer = Tools::getValue('id_customer');
|
|
$id_cart = Tools::getValue('id_cart');
|
|
$id_order = Tools::getValue('id_order');
|
|
|
|
if (!$id_pickup) {
|
|
die('No pickup ID retrieved');
|
|
}
|
|
if (!$id_customer) {
|
|
die('No customer ID retrieved');
|
|
}
|
|
if (!$id_cart) {
|
|
die('No cart ID retrieved');
|
|
}
|
|
if (!$id_order) {
|
|
die('No order ID retrieved');
|
|
}
|
|
|
|
$id_pickup = sprintf('%06s', $id_pickup);
|
|
|
|
$soflexibilite_api = new SoFlexibiliteWebService();
|
|
$relay = $soflexibilite_api->getRelay($id_pickup);
|
|
|
|
if ($relay instanceof stdClass && $relay->identifiant) {
|
|
$customer = new Customer($id_customer);
|
|
$order = new Order($id_order);
|
|
$invoice_address = new Address($order->id_address_invoice);
|
|
$delivery_address = new Address($order->id_address_delivery);
|
|
|
|
$so_delivery = new SoFlexibiliteDelivery();
|
|
$so_delivery->id_cart = (int)$id_cart;
|
|
$so_delivery->id_customer = (int)$id_customer;
|
|
|
|
$so_delivery->loadDelivery();
|
|
|
|
$so_delivery->id_order = $id_order;
|
|
$so_delivery->type = $relay->typeDePoint;
|
|
$so_delivery->id_point = $relay->identifiant;
|
|
$so_delivery->libelle = $relay->nom;
|
|
$so_delivery->firstname = $invoice_address->firstname;
|
|
$so_delivery->address1 = $invoice_address->address1;
|
|
$so_delivery->address2 = $invoice_address->address2;
|
|
$so_delivery->address3 = '';
|
|
$so_delivery->company = $invoice_address->company;
|
|
$so_delivery->indice = '';
|
|
$so_delivery->postcode = $invoice_address->postcode;
|
|
$so_delivery->city = $invoice_address->city;
|
|
$so_delivery->country = Country::getIsoById($invoice_address->id_country);
|
|
$so_delivery->lieudit = '';
|
|
|
|
$status = $so_delivery->saveDelivery() ? true : false;
|
|
|
|
// $delivery_address->company = $relay->nom;
|
|
// $delivery_address->address1 = $relay->adresse1;
|
|
// $delivery_address->address2 = $relay->adresse2;
|
|
// $delivery_address->postcode = $relay->codePostal;
|
|
// $delivery_address->city = $relay->localite;
|
|
// $delivery_address->country = $relay->libellePays;
|
|
// $delivery_address->id_country = Country::getByIso($relay->codePays);
|
|
//
|
|
// $status &= $delivery_address->save();
|
|
|
|
$json = array(
|
|
'output' => ob_get_clean(),
|
|
'status' => $status
|
|
);
|
|
die(Tools::jsonEncode($json));
|
|
}
|
|
|
|
$json = array(
|
|
'output' => ob_get_clean(),
|
|
'status' => false
|
|
);
|
|
die(Tools::jsonEncode($json));
|