diff --git a/controllers/front/OrderController.php b/controllers/front/OrderController.php index 49927ce98..fba49388c 100644 --- a/controllers/front/OrderController.php +++ b/controllers/front/OrderController.php @@ -249,15 +249,19 @@ class OrderControllerCore extends ParentOrderController { if (!Tools::getValue('multi-shipping')) $this->context->cart->setNoMultishipping(); - + + $same = Tools::isSubmit('same'); + if(!Tools::getValue('id_address_invoice', false) && !$same) + $same = true; + if (!Customer::customerHasAddress($this->context->customer->id, (int)Tools::getValue('id_address_delivery')) - || (!Tools::isSubmit('same') && Tools::getValue('id_address_delivery') != Tools::getValue('id_address_invoice') + || (!$same && Tools::getValue('id_address_delivery') != Tools::getValue('id_address_invoice') && !Customer::customerHasAddress($this->context->customer->id, (int)Tools::getValue('id_address_invoice')))) $this->errors[] = Tools::displayError('Invalid address', !Tools::getValue('ajax')); 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'); + $this->context->cart->id_address_invoice = $same ? $this->context->cart->id_address_delivery : (int)Tools::getValue('id_address_invoice'); CartRule::autoRemoveFromCart($this->context); CartRule::autoAddToCart($this->context);