[-] BO : forbid the creation of 2 cart rules with the same code #PSCFV-5737

This commit is contained in:
DamienMetzger
2012-11-21 10:59:37 +01:00
parent 9c8f31b42d
commit 3fe8ebec14
@@ -121,6 +121,8 @@ class AdminCartRulesControllerCore extends AdminController
$this->errors[] = Tools::displayError('Reduction percent must be between 0% and 100%');
if ((int)Tools::getValue('reduction_amount') < 0)
$this->errors[] = Tools::displayError('Reduction amount cannot be lower than 0');
if (Tools::getValue('code') && ($same_code = (int)CartRule::getIdByCode(Tools::getValue('code'))))
$this->errors[] = sprintf(Tools::displayError('This cart rule code is already used (conflict with cart rule %d)'), $same_code);
}
return parent::postProcess();