2016-10-12 12:40:33 +02:00
< ? 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' )
2016-10-12 16:45:24 +02:00
&& ( $mode = Tools :: getValue ( 'mode' ))
2016-10-12 12:40:33 +02:00
&& ( $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
2016-10-12 16:45:24 +02:00
AND ( `type` = " '. $mode .' " '.($mode == "BPR"?' OR `type` = " CDI " ':' ').' )
2016-10-12 12:40:33 +02:00
' )));
}
if ( Tools :: getValue ( 'getAD' )
&& ( $id_address = Tools :: getValue ( 'id_address' ))) {
2016-10-14 13:55:21 +02:00
$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 ) )));
2016-10-12 12:40:33 +02:00
}
}
die ( json_encode ( 'error1' ));
} else {
die ( json_encode ( 'error' ));
}