From fd64b3baec67c462786d61bbacb0a219a27cf31b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vincent=20de=20Grandpr=C3=A9?= Date: Sat, 13 Aug 2022 18:32:30 -0400 Subject: [PATCH] =?UTF-8?q?CLOSE=2021748=20Maillage=20sur=20ErrorProductAl?= =?UTF-8?q?readyExists=20en=20cr=C3=A9ant=20produit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/product/card.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 9137a3b7c10..a87920c43f2 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -19,6 +19,7 @@ * Copyright (C) 2019-2022 Frédéric France * Copyright (C) 2019-2020 Thibault FOUCART * Copyright (C) 2020 Pierre Ardoin + * Copyright (C) 2022 Vincent de Grandpré * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -666,7 +667,20 @@ if (empty($reshook)) { if (count($object->errors)) { setEventMessages($object->error, $object->errors, 'errors'); } else { - setEventMessages($langs->trans($object->error), null, 'errors'); + if($object->error == 'ErrorProductAlreadyExists') { + // permet une action personnallisée quand il y a tentative d'ajouter un produit + // avec un numéro de référence existant. + $reshook = $hookmanager->executeHooks('onProductAlreadyExists', $parameters, $object, $action); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } + if($object->error) { + // L'erreur de l'objet a pu être effacée par la fonction + setEventMessages($langs->trans($object->error), null, 'errors'); + } + } else { + setEventMessages($langs->trans($object->error), null, 'errors'); + } } $action = "create"; }