diff --git a/classes/AdminController.php b/classes/AdminController.php index 3149558b7..7a0acb30c 100644 --- a/classes/AdminController.php +++ b/classes/AdminController.php @@ -2280,6 +2280,9 @@ class AdminControllerCore extends Controller $assos = $assos_data[0]; $type = $assos_data[1]; + if (!$type) + return; + Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.$this->table.'_'.$type.($id_object ? ' WHERE `'.$this->identifier.'`='.(int)$id_object : '')); foreach ($assos as $asso) diff --git a/classes/Cart.php b/classes/Cart.php index 57149d558..d582de72c 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -1607,6 +1607,7 @@ class CartCore extends ObjectModel * ), * ), * ); + * If there are no carriers available for an address, return an empty array */ public function getDeliveryOptionList(Country $default_country = null, $flush = false) { diff --git a/controllers/front/OrderController.php b/controllers/front/OrderController.php index 4a96ba66a..8ed1d2225 100644 --- a/controllers/front/OrderController.php +++ b/controllers/front/OrderController.php @@ -185,6 +185,10 @@ class OrderControllerCore extends ParentOrderController if ($this->step >= 2 && (!$this->context->cart->id_address_delivery || !$this->context->cart->id_address_invoice)) Tools::redirect('index.php?controller=order&step=1'); + + if ($this->step > 2 && !$isVirtualCart && count($this->context->cart->getDeliveryOptionList()) == 0) + Tools::redirect('index.php?controller=order&step=2'); + $delivery = new Address((int)$this->context->cart->id_address_delivery); $invoice = new Address((int)$this->context->cart->id_address_invoice); diff --git a/controllers/front/OrderOpcController.php b/controllers/front/OrderOpcController.php index f1c51cabf..ab6062ecb 100644 --- a/controllers/front/OrderOpcController.php +++ b/controllers/front/OrderOpcController.php @@ -393,6 +393,13 @@ class OrderOpcControllerCore extends ParentOrderController $address_invoice = ($this->context->cart->id_address_delivery == $this->context->cart->id_address_invoice ? $address_delivery : new Address($this->context->cart->id_address_invoice)); if (!$this->context->cart->id_address_delivery OR !$this->context->cart->id_address_invoice OR !Validate::isLoadedObject($address_delivery) OR !Validate::isLoadedObject($address_invoice) OR $address_invoice->deleted OR $address_delivery->deleted) return '

'.Tools::displayError('Error: please choose an address').'

'; + if (count($this->context->cart->getDeliveryOptionList()) == 0) + { + if ($this->context->cart->isMultiAddressDelivery()) + return '

'.Tools::displayError('Error: There are no carriers available that deliver to some of your addresses').'

'; + else + return '

'.Tools::displayError('Error: There are no carriers available that deliver to this address').'

'; + } if (!$this->context->cart->getDeliveryOption() AND !$this->context->cart->isVirtualCart()) return '

'.Tools::displayError('Error: please choose a carrier').'

'; if (!$this->context->cart->id_currency) diff --git a/controllers/front/ParentOrderController.php b/controllers/front/ParentOrderController.php index 31b5eb98b..418dd03dd 100644 --- a/controllers/front/ParentOrderController.php +++ b/controllers/front/ParentOrderController.php @@ -394,20 +394,22 @@ class ParentOrderControllerCore extends FrontController $address = new Address($this->context->cart->id_address_delivery); $id_zone = Address::getZoneById($address->id); $carriers = $this->context->cart->simulateCarriersOutput(); + $checked = $this->context->cart->simulateCarrierSelectedOutput(); + $delivery_option_list = $this->context->cart->getDeliveryOptionList(); $this->context->smarty->assign(array( 'address_collection' => $this->context->cart->getAddressCollection(), - 'delivery_option_list' => $this->context->cart->getDeliveryOptionList(), + 'delivery_option_list' => $delivery_option_list, 'carriers' => $carriers, - 'checked' => $this->context->cart->simulateCarrierSelectedOutput(), + 'checked' => $checked, 'delivery_option' => $this->context->cart->getDeliveryOption() )); $this->context->smarty->assign(array( 'HOOK_EXTRACARRIER' => Hook::exec('extraCarrier', array('address' => $address)), 'HOOK_BEFORECARRIER' => Hook::exec('beforeCarrier', array( 'carriers' => $carriers, - 'checked' => $this->context->cart->simulateCarrierSelectedOutput(), - 'delivery_option_list' => $this->context->cart->getDeliveryOptionList(), + 'checked' => $checked, + 'delivery_option_list' => $delivery_option_list, 'delivery_option' => $this->context->cart->getDeliveryOption() )) )); diff --git a/themes/default/order-carrier.tpl b/themes/default/order-carrier.tpl index 8277dc0e6..ff11ac67c 100644 --- a/themes/default/order-carrier.tpl +++ b/themes/default/order-carrier.tpl @@ -180,8 +180,17 @@ {/foreach} + {foreachelse} +

+ {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} {/if} + @@ -231,7 +240,9 @@ {else} « {l s='Previous'} {/if} - + {if $virtual_cart || (isset($delivery_option_list) && !empty($delivery_option_list))} + + {/if}

{else}