2016-10-14 13:55:21 +02:00

62 lines
2.6 KiB
PHP

<?php
require_once(dirname(__FILE__).'../../../config/config.inc.php');
require_once(dirname(__FILE__).'../../../init.php');
require_once(dirname(__FILE__).'../../../modules/ant_changeaddress/ant_changeaddress.php');
$ant_changeaddress = new Ant_Changeaddress();
if($cookie->isLogged() && Tools::getValue('id_order')) {
if(Tools::getValue('getPR')
&& ($mode = Tools::getValue('mode'))
&& ($h_xcoords = (float) Tools::getValue('h_xcoords'))
&& ($h_ycoords = (float) Tools::getValue('h_ycoords'))) {
$pr_list = array();
header('Content-Type: text/json');
die(json_encode(Db::getInstance()->ExecuteS('
SELECT *
FROM `'._DB_PREFIX_.'lapostews_pr`
WHERE `ycoords` >= '.(float) $h_ycoords.' - 0.02
AND `ycoords` <= '.(float) $h_ycoords.' + 0.02
AND `xcoords` >= '.(float) $h_xcoords.' - 0.01
AND `xcoords` <= '.(float) $h_xcoords.' + 0.01
AND (`type` = "'.$mode.'"'.($mode == "BPR"?' OR `type` = "CDI"':'').')
')));
}
if(Tools::getValue('getAD')
&& ($id_address = Tools::getValue('id_address'))) {
$errors = array();
$delivery = new Address((int)$id_address);
$prefix_postcode = substr($delivery->postcode, 0 ,2);
if ($delivery->id_country == 6
&& (intval($prefix_postcode) == 35 || intval($prefix_postcode) == 38)
) {
$errors[] = Tools::displayError('Lo sentimos, en estos momentos no distribuimos nuestros productos en Canarias. Si deseas más información, puedes contactar con el Servicio de atención al cliente o llamar al 902 044 399.');
}
// bloque DOM-TOM
$prefix_postcode = substr($delivery->postcode, 0 ,3);
$domtom = array(971,972,973,974,975,976,984,986,987,988);
if ($delivery->id_country == 8 && (in_array(intval($prefix_postcode),$domtom))
) {
$errors[] = Tools::displayError('Nous sommes désolé, nous ne livrons pas dans le DOM-TOM');
}
if(empty($errors)) {
$change_address = $ant_changeaddress->getAddress($id_address);
$html = '';
foreach ($change_address as $key => $value) {
$html .= '<li>'.$value.'</li>';
}
header('Content-Type: text/json');
die(json_encode(array("error"=>"false","text" => $html)));
} else {
header('Content-Type: text/json');
die(json_encode(array("error"=>"true","text" => implode("</br>", $errors) )));
}
}
die(json_encode('error1'));
} else {
die(json_encode('error'));
}