[-] FO : #PSCFV-2158 - Add warning message when a product cannot be delivered to an address
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@15021 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -1124,6 +1124,10 @@ class CarrierCore extends ObjectModel
|
||||
{
|
||||
$address = new Address($id_address);
|
||||
$id_zone = Address::getZoneById($address->id);
|
||||
|
||||
// Check the country of the address is activated
|
||||
if (!Address::isCountryActiveById($address->id))
|
||||
return array();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -3307,4 +3307,31 @@ class CartCore extends ObjectModel
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the ids of the delivery addresses without carriers
|
||||
*
|
||||
* @param bool $return_collection Return a collection
|
||||
*
|
||||
* @return array Array of address id or of address object
|
||||
*/
|
||||
public function getDeliveryAddressesWithoutCarriers($return_collection = false)
|
||||
{
|
||||
$addresses_without_carriers = array();
|
||||
foreach ($this->getProducts() as $product)
|
||||
{
|
||||
if (!in_array($product['id_address_delivery'], $addresses_without_carriers)
|
||||
&& !count(Carrier::getAvailableCarrierList(new Product($product['id_product']), null, $product['id_address_delivery'])))
|
||||
$addresses_without_carriers[] = $product['id_address_delivery'];
|
||||
}
|
||||
if (!$return_collection)
|
||||
return $addresses_without_carriers;
|
||||
else
|
||||
{
|
||||
$addresses_instance_without_carriers = array();
|
||||
foreach ($addresses_without_carriers as $id_address)
|
||||
$addresses_instance_without_carriers[] = new Address($id_address);
|
||||
return $addresses_instance_without_carriers;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,9 +146,12 @@ abstract class PaymentModuleCore extends Module
|
||||
foreach ($packageByAddress as $id_package => $package)
|
||||
{
|
||||
$product_list = $package['product_list'];
|
||||
$carrier = new Carrier($package['id_carrier'], $cart->id_lang);
|
||||
$order = new Order();
|
||||
$order->id_carrier = (int)$carrier->id;
|
||||
if (isset($package['id_carrier']))
|
||||
{
|
||||
$carrier = new Carrier($package['id_carrier'], $cart->id_lang);
|
||||
$order->id_carrier = (int)$carrier->id;
|
||||
}
|
||||
$order->id_customer = (int)$cart->id_customer;
|
||||
$order->id_address_invoice = (int)$cart->id_address_invoice;
|
||||
$order->id_address_delivery = (int)$id_address;
|
||||
|
||||
@@ -126,6 +126,12 @@ class CartControllerCore extends FrontController
|
||||
$old_id_address_delivery = (int)Tools::getValue('old_id_address_delivery');
|
||||
$new_id_address_delivery = (int)Tools::getValue('new_id_address_delivery');
|
||||
|
||||
if (!count(Carrier::getAvailableCarrierList(new Product($this->id_product), null, $new_id_address_delivery)))
|
||||
die(Tools::jsonEncode(array(
|
||||
'hasErrors' => true,
|
||||
'error' => Tools::displayError('It\'s not possible to deliver this product to the selected address.', false),
|
||||
)));
|
||||
|
||||
$this->context->cart->setProductAddressDelivery(
|
||||
$this->id_product,
|
||||
$this->id_product_attribute,
|
||||
|
||||
@@ -238,9 +238,16 @@ class OrderControllerCore extends ParentOrderController
|
||||
$this->context->cart->setNoMultishipping();
|
||||
|
||||
// Add checking for all addresses
|
||||
|
||||
if (!Tools::isSubmit('id_address_delivery') || !Address::isCountryActiveById((int)Tools::getValue('id_address_delivery')))
|
||||
$this->errors[] = Tools::displayError('This address is not in a valid area.');
|
||||
$address_without_carriers = $this->context->cart->getDeliveryAddressesWithoutCarriers();
|
||||
if (count($address_without_carriers))
|
||||
{
|
||||
if (count($address_without_carriers) > 1)
|
||||
$this->errors[] = sprintf(Tools::displayError('There are no carriers that deliver to some addresses you selected.'));
|
||||
elseif ($this->context->cart->isMultiAddressDelivery())
|
||||
$this->errors[] = sprintf(Tools::displayError('There are no carriers that deliver to one of the address you selected.'));
|
||||
else
|
||||
$this->errors[] = sprintf(Tools::displayError('There are no carriers that deliver to the address you selected.'));
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->context->cart->id_address_delivery = (int)Tools::getValue('id_address_delivery');
|
||||
|
||||
@@ -197,7 +197,6 @@ class OrderOpcControllerCore extends ParentOrderController
|
||||
|
||||
if (!count($this->errors))
|
||||
{
|
||||
$result = $this->_getCarrierList();
|
||||
// Wrapping fees
|
||||
$wrapping_fees = (float)(Configuration::get('PS_GIFT_WRAPPING_PRICE'));
|
||||
$wrapping_fees_tax = new Tax((int)(Configuration::get('PS_GIFT_WRAPPING_TAX')));
|
||||
@@ -213,7 +212,10 @@ class OrderOpcControllerCore extends ParentOrderController
|
||||
}
|
||||
}
|
||||
if (count($this->errors))
|
||||
die('{"hasError" : true, "errors" : ["'.implode('\',\'', $this->errors).'"]}');
|
||||
die(Tools::jsonEncode(array(
|
||||
'hasError' => true,
|
||||
'errors' => $this->errors
|
||||
)));
|
||||
}
|
||||
die(Tools::displayError());
|
||||
break;
|
||||
@@ -504,7 +506,8 @@ class OrderOpcControllerCore extends ParentOrderController
|
||||
if (count($this->errors))
|
||||
return array(
|
||||
'hasError' => true,
|
||||
'errors' => $this->errors
|
||||
'errors' => $this->errors,
|
||||
'carrier_block' => $this->context->smarty->fetch(_PS_THEME_DIR_.'order-carrier.tpl')
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -99,28 +99,37 @@ function changeAddressDelivery(obj)
|
||||
+'&allow_refresh=1',
|
||||
success: function(jsonData)
|
||||
{
|
||||
// The product exist
|
||||
if ($('#product_'+id_product+'_'+id_product_attribute+'_0_'+new_id_address_delivery).length)
|
||||
if (typeof(jsonData.hasErrors) != 'undefined' && jsonData.hasErrors)
|
||||
{
|
||||
updateCustomizedDatas(jsonData.customizedDatas);
|
||||
updateCartSummary(jsonData.summary);
|
||||
updateHookShoppingCart(jsonData.HOOK_SHOPPING_CART);
|
||||
updateHookShoppingCartExtra(jsonData.HOOK_SHOPPING_CART_EXTRA);
|
||||
if (typeof(getCarrierListAndUpdate) != 'undefined')
|
||||
getCarrierListAndUpdate();
|
||||
|
||||
// @todo reverse the remove order
|
||||
// This effect remove the current line, but it's better to remove the other one, and refresshing this one
|
||||
$('#product_'+id_product+'_'+id_product_attribute+'_0_'+old_id_address_delivery).remove();
|
||||
|
||||
// @todo improve customization upgrading
|
||||
$('.product_'+id_product+'_'+id_product_attribute+'_0_'+old_id_address_delivery).remove();
|
||||
alert(jsonData.error);
|
||||
// Reset the old address
|
||||
$('#select_address_delivery_'+id_product+'_'+id_product_attribute+'_'+old_id_address_delivery).val(old_id_address_delivery);
|
||||
}
|
||||
else
|
||||
{
|
||||
// The product exist
|
||||
if ($('#product_'+id_product+'_'+id_product_attribute+'_0_'+new_id_address_delivery).length)
|
||||
{
|
||||
updateCustomizedDatas(jsonData.customizedDatas);
|
||||
updateCartSummary(jsonData.summary);
|
||||
updateHookShoppingCart(jsonData.HOOK_SHOPPING_CART);
|
||||
updateHookShoppingCartExtra(jsonData.HOOK_SHOPPING_CART_EXTRA);
|
||||
if (typeof(getCarrierListAndUpdate) != 'undefined')
|
||||
getCarrierListAndUpdate();
|
||||
|
||||
// @todo reverse the remove order
|
||||
// This effect remove the current line, but it's better to remove the other one, and refresshing this one
|
||||
$('#product_'+id_product+'_'+id_product_attribute+'_0_'+old_id_address_delivery).remove();
|
||||
|
||||
// @todo improve customization upgrading
|
||||
$('.product_'+id_product+'_'+id_product_attribute+'_0_'+old_id_address_delivery).remove();
|
||||
}
|
||||
|
||||
if (window.ajaxCart !== undefined)
|
||||
ajaxCart.refresh();
|
||||
updateAddressId(id_product, id_product_attribute, old_id_address_delivery, new_id_address_delivery);
|
||||
cleanSelectAddressDelivery();
|
||||
}
|
||||
|
||||
if (window.ajaxCart !== undefined)
|
||||
ajaxCart.refresh();
|
||||
updateAddressId(id_product, id_product_attribute, old_id_address_delivery, new_id_address_delivery);
|
||||
cleanSelectAddressDelivery();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -192,6 +201,7 @@ function changeAddressDelivery(obj)
|
||||
}
|
||||
});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function updateAddressId(id_product, id_product_attribute, old_id_address_delivery, id_address_delivery, line)
|
||||
|
||||
@@ -201,11 +201,12 @@
|
||||
<div class="hook_extracarrier" id="HOOK_EXTRACARRIER_{$id_address}">{if isset($HOOK_EXTRACARRIER_ADDR)}{$HOOK_EXTRACARRIER_ADDR.$id_address}{/if}</div>
|
||||
{foreachelse}
|
||||
<p class="warning" id="noCarrierWarning">
|
||||
{if $cart->isMultiAddressDelivery()}
|
||||
{l s='There are no carriers available that deliver to some of your addresses.'}
|
||||
{else}
|
||||
{l s='There are no carriers available that deliver to this address.'}
|
||||
{/if}
|
||||
{foreach $cart->getDeliveryAddressesWithoutCarriers(true) as $address}
|
||||
{l s='No carriers available for the address "%s".' sprintf=$address->alias}
|
||||
{if !$address@last}
|
||||
<br />
|
||||
{/if}
|
||||
{/foreach}
|
||||
</p>
|
||||
{/foreach}
|
||||
{/if}
|
||||
|
||||
@@ -130,6 +130,7 @@ $_ERRORS['31fe542f8c37c61360c21d904e59bf41'] = 'La commande ne peut être renouv
|
||||
$_ERRORS['32a2e7694628335252aceb0552a6f6ba'] = 'Pour utiliser Memcached, vous devez installer l\'extension PECL Memcache sur votre serveur.';
|
||||
$_ERRORS['32d841e578ff7560bbaeda96f5328e9e'] = 'Serveur de média n°2 non valable';
|
||||
$_ERRORS['34843eb626c7fbe22db113fca38197b7'] = 'Une erreur s\'est produite durant la transformation d\'un client invité.';
|
||||
$_ERRORS['34bff86ac3ed2450ae5b4c562f353115'] = 'Il n\'y a pas de transporteur qui livre à l\'une des adresses sélectionnées.';
|
||||
$_ERRORS['3549b9f409be47593858dbe1a546c978'] = 'Une erreur s\'est produite : impossible d\'enregistrer la règle de taxe actuelle';
|
||||
$_ERRORS['36527e8d64ec4ced95607f6ef9b2a1b9'] = 'Facture introuvable';
|
||||
$_ERRORS['366da0581c44d3c179e44f532b693eab'] = 'L\'IP Memcached est manquante';
|
||||
@@ -301,6 +302,7 @@ $_ERRORS['774eec2772b5f57b2e13d11e1b093a4f'] = 'Aucune image trouvée pour la d
|
||||
$_ERRORS['77ae44aa6c998166fcf1a87496278ad5'] = '(impossible de charger l\'objet)';
|
||||
$_ERRORS['77cfbabd503d856f294f28a6a0e8b8f2'] = 'La quantité n\'est pas valable.';
|
||||
$_ERRORS['780e67070a71f981346201c4810dc9d4'] = 'Vous devez saisir un montant si vous voulez créer un remboursement partiel';
|
||||
$_ERRORS['78c46e5c6e68799668e5b0af361e8e5d'] = 'Il n\'y a pas de transporteur qui livre à certaines adresses sélectionnées.';
|
||||
$_ERRORS['78fd3fe8e01d0707107ced7ade92d23d'] = 'Une erreur est survenue lors du lien de l\'objet.';
|
||||
$_ERRORS['790198fa9161355e1d60a6c42104e430'] = 'Un compte est déjà enregistré avec cet e-mail, veuillez renseigner le mot de passe ou en demander un nouveau.';
|
||||
$_ERRORS['79037dcfa176cabd85c98785a5882681'] = 'La devise sélectionnée n\'est pas valable.';
|
||||
@@ -393,6 +395,7 @@ $_ERRORS['a56b6c43645970e79a8098df1dfc9746'] = 'Cette adresse ne peut pas être
|
||||
$_ERRORS['a5df8bfce318a15ea55f18082b9b56c0'] = 'Vous n\'avez pas accès à ce produit.';
|
||||
$_ERRORS['a693c37913e1fac5af61b8247c03b6ca'] = 'Le ou les modules suivants n\'ont pas été correctement mis à jour : %s';
|
||||
$_ERRORS['a6bff806eca0f27ddc2118218517e690'] = 'Vous devez ajouter';
|
||||
$_ERRORS['a6cc8cbe3fa07d0fca172c36a603332c'] = 'Aucun transporteur disponibles pour l\'adresse \"%s\".';
|
||||
$_ERRORS['a7642593a28353de8256fc0e4bc3bc40'] = 'Ce module doit être installé pour être mis à jour :';
|
||||
$_ERRORS['a78ac92432df02a17a667fdc15764454'] = 'Le moteur de rendu sélectionné n\'est pas disponible.';
|
||||
$_ERRORS['a7b770c4221d81830ac09059e16083a8'] = 'L\'identifiant du transporteur de cette commande n\'est pas valable';
|
||||
@@ -494,6 +497,7 @@ $_ERRORS['ce30da82a4a6b974c18780af4597c8ee'] = 'Une erreur est survenue pendant
|
||||
$_ERRORS['cf325676512d19d8150c0244327926df'] = 'Ne peut être copié';
|
||||
$_ERRORS['cf8a93e045f508c8a3c6430084f45825'] = 'Une erreur s\'est produite. Aucun stock n\'a été ajouté.';
|
||||
$_ERRORS['cfb0a6025f8279ec130db5d2883ead88'] = 'Une erreur s\'est produite pendant la mise à jour des paramètres de la personnalisation.';
|
||||
$_ERRORS['d049e05d0babc4c1643c4b36397be24d'] = 'Il n\'y a pas de transporteur qui livre à l\'adresse sélectionnée.';
|
||||
$_ERRORS['d0f1560c5d1b13b1e64fa87a301dd83b'] = 'Ce bon de réduction se trouve déjà dans votre panier';
|
||||
$_ERRORS['d107b93e0404a9ec3a24c3b797b63fff'] = 'Aucun remboursement trouvé';
|
||||
$_ERRORS['d14e88e2344c5dba06dad332a7f74726'] = 'Vous devez d\'abord choisir un transporteur';
|
||||
@@ -614,6 +618,7 @@ $_ERRORS['f996dce5bdfb1b1094e41cf996c5fdae'] = 'Veuillez indiquer l\'URL du modu
|
||||
$_ERRORS['f9c47597596f7159815c61957f4f8ec2'] = '%1$s (erreur de syntaxe dans %2$s)';
|
||||
$_ERRORS['f9c7939a8397ee022fefee2bdb3407af'] = 'URL non valable';
|
||||
$_ERRORS['f9cc33cd720db1551338663f0ed0cc78'] = 'Vous n\'avez pas les droits pour ajouter du stock.';
|
||||
$_ERRORS['fbd5f59dcc8b961a5e953fafa7238cd3'] = 'Impossible de livrer ce produit à l\'adresse sélectionnée.';
|
||||
$_ERRORS['fd3d2771d53d8e29bb0d79d00cf3696d'] = 'L\'employé doit être associé à au moins une boutique';
|
||||
$_ERRORS['fd6034a1544218709264bfa5c70ffb69'] = 'Vous ne pouvez pas utiliser ce bon de réduction dans votre pays de livraison';
|
||||
$_ERRORS['fe22b7cb2de47c8eafec2ad82fada9dd'] = 'Le produit doit être créé avant d\'ajouter des possibilités de personnalisations.';
|
||||
|
||||
Reference in New Issue
Block a user