pfs007 Posted June 20, 2015 Share Posted June 20, 2015 (edited) Bonjour, Je cherche un moyen de tester si un client qui se connecte à ma boutique possède encore au moins un bon d'achat valable attaché à son nom. L'objectif est de le mettre automatiquement dans un groupe donné s'il n'a plus aucun coupon. J'ai déjà le code pour le changer de groupe : /* PFS ajouté pour affectation au groupe */ $id_customer = (int)$this->context->customer->id; if (Db::getInstance()->getValue(' SELECT COUNT(*) FROM `' . _DB_PREFIX_ . 'cart_rule` WHERE id_customer = ' . $id_customer . ' AND `quantity` = 1' ) = 0) { $customer = new Customer($id_customer); $id_special_group = 3; $customer->cleanGroups(); $customer->addGroups(array($id_special_group)); $customer->id_default_group = $id_special_group; } /* PFS */ Merci de votre aide. Bon week-end. PFS Edited June 20, 2015 by pfs007 (see edit history) Link to comment Share on other sites More sharing options...
pfs007 Posted June 21, 2015 Author Share Posted June 21, 2015 (edited) Bonjour, J'ai créé un override de AuthController.php. J'insère mon code, et je sais que l'interrogation de la BDD fonctionne, je l'ai testé par ailleurs. Et pourtant, j'ai cette erreur : Fatal error: Can't use method return value in write context in override/controllers/front/AuthController.php on line 15 La ligne 15 est : ") = 0)" Voilà mon fichier d'override : <?php class AuthController extends AuthControllerCore { public function postProcess() { parent::postProcess(); $id_customerPFS = (int)$this->context->customer->id; if (Db::getInstance()->getValue(' SELECT COUNT(*) FROM `' . _DB_PREFIX_ . 'cart_rule` WHERE `id_customer` = ' . $id_customerPFS . ' AND `quantity` = 1' ) = 0) { $customer = new Customer($id_customerPFS); $id_special_group = 3; $customer->cleanGroups(); $customer->addGroups(array($id_special_group)); $customer->id_default_group = $id_special_group; return true; } else { $id_customerPFS = (int)$this->context->customer->id; $customer = new Customer($id_customerPFS); $id_special_group = 4; $customer->cleanGroups(); $customer->addGroups(array($id_special_group)); $customer->id_default_group = $id_special_group; return true; } } } ?> Merci de votre aide. PFS Edited June 21, 2015 by pfs007 (see edit history) Link to comment Share on other sites More sharing options...
EISEAL Posted June 21, 2015 Share Posted June 21, 2015 (edited) Salut, Tu dois etre en PHP 5, il faut que tu sortes ta requête du "if", fais comme ça : $toto = Db::getInstance()->getValue(' SELECT COUNT(*) FROM `' . _DB_PREFIX_ . 'cart_rule` WHERE `id_customer` = ' . $id_customerPFS . ' AND `quantity` = 1' ); if ($toto = 0) { Edited June 21, 2015 by anteverce (see edit history) Link to comment Share on other sites More sharing options...
pfs007 Posted June 21, 2015 Author Share Posted June 21, 2015 @anteverce Génial, merci, je n'aurais jamais trouvé tout seul ! C'est maintenant résolu ! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now