// Code cleaning

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@16830 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
dMetzger
2012-08-13 16:51:00 +00:00
parent e930b9b8ed
commit 96040e1cb5
+27 -21
View File
@@ -244,32 +244,38 @@ class OrderControllerCore extends ParentOrderController
{ {
if (!Tools::getValue('multi-shipping')) if (!Tools::getValue('multi-shipping'))
$this->context->cart->setNoMultishipping(); $this->context->cart->setNoMultishipping();
// Add checking for all addresses if (!Customer::customerHasAddress($this->context->customer->id, (int)Tools::getValue('id_address_delivery'))
$address_without_carriers = $this->context->cart->getDeliveryAddressesWithoutCarriers(); || (Tools::isSubmit('same') && !Customer::customerHasAddress($this->context->customer->id, (int)Tools::getValue('id_address_invoice'))))
if (count($address_without_carriers)) $this->errors[] = Tools::displayError('Invalid address');
{
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 else
{ {
$this->context->cart->id_address_delivery = (int)Tools::getValue('id_address_delivery'); // Add checking for all addresses
$this->context->cart->id_address_invoice = Tools::isSubmit('same') ? $this->context->cart->id_address_delivery : (int)Tools::getValue('id_address_invoice'); $address_without_carriers = $this->context->cart->getDeliveryAddressesWithoutCarriers();
if (!$this->context->cart->update()) if (count($address_without_carriers))
$this->errors[] = Tools::displayError('An error occurred while updating your cart.'); {
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');
$this->context->cart->id_address_invoice = Tools::isSubmit('same') ? $this->context->cart->id_address_delivery : (int)Tools::getValue('id_address_invoice');
if (!$this->context->cart->update())
$this->errors[] = Tools::displayError('An error occurred while updating your cart.');
if (!$this->context->cart->isMultiAddressDelivery()) if (!$this->context->cart->isMultiAddressDelivery())
$this->context->cart->setNoMultishipping(); // If there is only one delivery address, set each delivery address lines with the main delivery address $this->context->cart->setNoMultishipping(); // If there is only one delivery address, set each delivery address lines with the main delivery address
if (Tools::isSubmit('message')) if (Tools::isSubmit('message'))
$this->_updateMessage(Tools::getValue('message')); $this->_updateMessage(Tools::getValue('message'));
}
} }
if ($this->errors) if ($this->errors)
{ {
if (Tools::getValue('ajax')) if (Tools::getValue('ajax'))