Merge branch 'ticket-ChangeDeliveryAddress' into develop

This commit is contained in:
Marion Muszynski 2016-10-14 13:55:38 +02:00
commit a42ec3e70b
3 changed files with 43 additions and 8 deletions

View File

@ -24,13 +24,37 @@ if($cookie->isLogged() && Tools::getValue('id_order')) {
if(Tools::getValue('getAD')
&& ($id_address = Tools::getValue('id_address'))) {
$change_address = $ant_changeaddress->getAddress($id_address);
$html = '';
foreach ($change_address as $key => $value) {
$html .= '<li>'.$value.'</li>';
$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) )));
}
header('Content-Type: text/json');
die(json_encode($html));
}
die(json_encode('error1'));
} else {

View File

@ -16,6 +16,10 @@
font-size: 14px;
color: #514c8c;
}
#module-ant_changeaddress-change_address #center_column form p.error{
width: 300px;
margin: 0 auto;
}
#module-ant_changeaddress-change_address #center_column .button_large{
text-align: center;
text-transform: none;

View File

@ -12,6 +12,7 @@
{if $delivery_mode == "DOM"}
<p class="error" style="display: none;"></p>
<p class="address_delivery select">
<label for="id_address_delivery">{l s='Choose a delivery address:' mod='ant_changeaddress'}</label>
<select name="id_address_delivery" id="id_address_delivery" class="address_select">
@ -307,8 +308,14 @@
token : static_token
},
success: function(jsonData) {
$("ul.address_box").empty();
$("ul.address_box").html(jsonData);
if(jsonData.error == "false") {
$("p.error").hide();
$("ul.address_box").empty();
$("ul.address_box").html(jsonData.text);
} else{
$("p.error").html(jsonData.text);
$("p.error").show();
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {alert("TECHNICAL ERROR: unable to get update address \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);}
});