Merge branch 'ticket-ChangeDeliveryAddress' into develop

This commit is contained in:
Marion Muszynski 2016-10-14 15:10:29 +02:00
commit f1e58c8551
3 changed files with 34 additions and 4 deletions

View File

@ -23,18 +23,21 @@ if($cookie->isLogged() && Tools::getValue('id_order')) {
} }
if(Tools::getValue('getAD') if(Tools::getValue('getAD')
&& ($id_address = Tools::getValue('id_address'))) { && ($id_address = Tools::getValue('id_address'))
&& ($id_cart = Tools::getValue('id_cart'))) {
$errors = array(); $errors = array();
$order_cart = new Cart((int)$id_cart);
$delivery = new Address((int)$id_address); $delivery = new Address((int)$id_address);
$prefix_postcode = substr($delivery->postcode, 0 ,2); $prefix_postcode = substr($delivery->postcode, 0 ,2);
// Checking CANARIES
if ($delivery->id_country == 6 if ($delivery->id_country == 6
&& (intval($prefix_postcode) == 35 || intval($prefix_postcode) == 38) && (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.'); $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 // Checking DOM-TOM
$prefix_postcode = substr($delivery->postcode, 0 ,3); $prefix_postcode = substr($delivery->postcode, 0 ,3);
$domtom = array(971,972,973,974,975,976,984,986,987,988); $domtom = array(971,972,973,974,975,976,984,986,987,988);
@ -43,6 +46,17 @@ if($cookie->isLogged() && Tools::getValue('id_order')) {
$errors[] = Tools::displayError('Nous sommes désolé, nous ne livrons pas dans le DOM-TOM'); $errors[] = Tools::displayError('Nous sommes désolé, nous ne livrons pas dans le DOM-TOM');
} }
// Checking only in france
$products_only_fr = array();
foreach($order_cart->getProducts() as $product) {
if(($sale = Sale::getSaleFromCategory($product['id_category_default'])) !== NULL) {
// shipping only in france
if($sale->shipping_fr == 1 && $delivery->id_country != 8) {
$errors[] = Tools::displayError('Votre commande contient des produits expédiés uniquement en France');
}
}
}
if(empty($errors)) { if(empty($errors)) {
$change_address = $ant_changeaddress->getAddress($id_address); $change_address = $ant_changeaddress->getAddress($id_address);
$html = ''; $html = '';

View File

@ -74,20 +74,32 @@ if ($cookie->isLogged()) {
$delivery = new Address((int)$newAddressId); $delivery = new Address((int)$newAddressId);
$prefix_postcode = substr($delivery->postcode, 0 ,2); $prefix_postcode = substr($delivery->postcode, 0 ,2);
// Checking CANARIES
if ($delivery->id_country == 6 if ($delivery->id_country == 6
&& (intval($prefix_postcode) == 35 || intval($prefix_postcode) == 38) && (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.'); $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 // Checking DOM-TOM
$prefix_postcode = substr($delivery->postcode, 0 ,3); $prefix_postcode = substr($delivery->postcode, 0 ,3);
$domtom = array(971,972,973,974,975,976,984,986,987,988); $domtom = array(971,972,973,974,975,976,984,986,987,988);
if ($delivery->id_country == 8 && (in_array(intval($prefix_postcode),$domtom)) 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'); $errors[] = Tools::displayError('Nous sommes désolé, nous ne livrons pas dans le DOM-TOM');
} }
// Checking only in france
$products_only_fr = array();
foreach($order_cart->getProducts() as $product) {
if(($sale = Sale::getSaleFromCategory($product['id_category_default'])) !== NULL) {
// shipping only in france
if($sale->shipping_fr == 1 && $delivery->id_country != 8) {
$errors[] = Tools::displayError('Votre commande contient des produits expédiés uniquement en France');
}
}
}
if (empty($errors)) { if (empty($errors)) {
$order->id_address_delivery = (int)$newAddressId; $order->id_address_delivery = (int)$newAddressId;
$order->update(); $order->update();

View File

@ -305,16 +305,20 @@
id_order : {/literal}{$order->id}{literal}, id_order : {/literal}{$order->id}{literal},
getAD : 1, getAD : 1,
id_address : id_address, id_address : id_address,
id_cart : {/literal}{$order->id_cart}{literal},
token : static_token token : static_token
}, },
success: function(jsonData) { success: function(jsonData) {
$("div.error").hide();
if(jsonData.error == "false") { if(jsonData.error == "false") {
$("p.error").hide(); $("p.error").hide();
$("ul.address_box").empty(); $("ul.address_box").empty();
$("ul.address_box").html(jsonData.text); $("ul.address_box").html(jsonData.text);
$("input[name='submitChangeAddress']").show();
} else{ } else{
$("p.error").html(jsonData.text); $("p.error").html(jsonData.text);
$("p.error").show(); $("p.error").show();
$("input[name='submitChangeAddress']").hide();
} }
}, },
error: function(XMLHttpRequest, textStatus, errorThrown) {alert("TECHNICAL ERROR: unable to get update address \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);} error: function(XMLHttpRequest, textStatus, errorThrown) {alert("TECHNICAL ERROR: unable to get update address \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);}