diff --git a/modules/crossselling/crossselling.php b/modules/crossselling/crossselling.php index 708920a28..a6bf1eae1 100755 --- a/modules/crossselling/crossselling.php +++ b/modules/crossselling/crossselling.php @@ -54,7 +54,8 @@ class CrossSelling extends Module !$this->registerHook('productFooter') OR !$this->registerHook('header') OR !$this->registerHook('shoppingCart') OR - !Configuration::updateValue('CROSSSELLING_DISPLAY_PRICE', 0)) + !Configuration::updateValue('CROSSSELLING_DISPLAY_PRICE', 0) OR + !Configuration::updateValue('CROSSSELLING_NBR', 10)) return false; return true; } @@ -65,7 +66,8 @@ class CrossSelling extends Module !$this->unregisterHook('productFooter') OR !$this->unregisterHook('header') OR !$this->unregisterHook('shoppingCart') OR - !Configuration::deleteByName('CROSSSELLING_DISPLAY_PRICE')) + !Configuration::deleteByName('CROSSSELLING_DISPLAY_PRICE') OR + !Configuration::deleteByName('CROSSSELLING_NBR')) return false; return true; } @@ -73,12 +75,21 @@ class CrossSelling extends Module public function getContent() { $this->_html = ''; - if (Tools::isSubmit('submitCross') AND Tools::getValue('displayPrice') != 0 AND Tools::getValue('displayPrice') != 1) - $this->_html .= $this->displayError('Invalid displayPrice'); - elseif (Tools::isSubmit('submitCross')) + + if (Tools::isSubmit('submitCross')) { - Configuration::updateValue('CROSSSELLING_DISPLAY_PRICE', (int)Tools::getValue('displayPrice')); - $this->_html .= $this->displayConfirmation($this->l('Settings updated successfully')); + if (Tools::getValue('displayPrice') != 0 AND Tools::getValue('displayPrice') != 1) + $this->_html .= $this->displayError('Invalid displayPrice'); + else if (!($productNbr = Tools::getValue('productNbr')) || empty($productNbr)) + $this->_html .= $this->displayError('You must fill in the \'Products displayed\' field.'); + elseif ((int)($productNbr) == 0) + $this->_html .= $this->displayError('Invalid number.'); + else + { + Configuration::updateValue('CROSSSELLING_DISPLAY_PRICE', (int)Tools::getValue('displayPrice')); + Configuration::updateValue('CROSSSELLING_NBR', (int)Tools::getValue('productNbr')); + $this->_html .= $this->displayConfirmation($this->l('Settings updated successfully')); + } } $this->_html .= '