diff --git a/classes/Cart.php b/classes/Cart.php index 83581769c..f60461ac1 100644 --- a/classes/Cart.php +++ b/classes/Cart.php @@ -1322,7 +1322,7 @@ class CartCore extends ObjectModel return Tools::displayError('This voucher is not yet valid'); if (strtotime($discountObj->date_to) < time()) return Tools::displayError('This voucher has expired.'); - if (!$discountObj->availableWithShop($shop)) + if (!$discountObj->isAssociatedToShop($shop)) return Tools::displayError('This voucher is not available with this shop.'); if (sizeof($discounts) >= 1 AND $checkCartDiscount) { diff --git a/classes/Discount.php b/classes/Discount.php index 147854d41..1a8fad8b0 100644 --- a/classes/Discount.php +++ b/classes/Discount.php @@ -483,18 +483,4 @@ class DiscountCore extends ObjectModel { return Db::getInstance()->getRow('SELECT * FROM `'._DB_PREFIX_.'discount` WHERE `id_discount` = '.(int)$id_discount); } - - public function availableWithShop(Shop $shop = null) - { - if (!$shop) - $shop = Context::getContext()->shop; - - // @todo share datas on discount ? Utility of this function ? - $sql = 'SELECT id_discount - FROM '._DB_PREFIX_.'discount - WHERE id_discount = '.(int)$this->id - .$shop->sqlRestriction(false); - return Db::getInstance()->getValue($sql); - } } - diff --git a/classes/Dispatcher.php b/classes/Dispatcher.php index 90a0416ac..e4107f8c4 100644 --- a/classes/Dispatcher.php +++ b/classes/Dispatcher.php @@ -190,6 +190,8 @@ class DispatcherCore // Get and instantiate controller $this->getController(); $controllers = Dispatcher::getControllers(); + if (!$this->controller) + $this->controller = 'index'; if (!isset($controllers[$this->controller])) $this->controller = 'pagenotfound'; ControllerFactory::getController($controllers[$this->controller])->run(); @@ -323,7 +325,7 @@ class DispatcherCore if (!isset($this->routes[$routeID])) { $query = http_build_query($params); - return 'index.php?controller='.$routeID.(($query) ? '&'.$query : ''); + return ($routeID == 'index') ? 'index.php'.(($query) ? '?'.$query : '') : 'index.php?controller='.$routeID.(($query) ? '&'.$query : ''); } $route = $this->routes[$routeID]; @@ -408,7 +410,7 @@ class DispatcherCore } // Default mode, take controller from url else - $this->controller = (!empty($controller)) ? $controller : 'index'; + $this->controller = $controller; $this->controller = str_replace('-', '', strtolower($this->controller)); return $this->controller;