create error message when a customer is deleted and already have orders.
Fix #199
This commit is contained in:
@@ -31,6 +31,8 @@ use Thelia\Core\Event\LostPasswordEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Core\Security\SecurityContext;
|
||||
use Thelia\Core\Template\ParserInterface;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Exception\CustomerException;
|
||||
use Thelia\Mailer\MailerFactory;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Model\Customer as CustomerModel;
|
||||
@@ -106,6 +108,10 @@ class Customer extends BaseAction implements EventSubscriberInterface
|
||||
{
|
||||
if (null !== $customer = $event->getCustomer()) {
|
||||
|
||||
if (true === $customer->hasOrder()) {
|
||||
throw new CustomerException(Translator::getInstance()->trans("Impossible to delete a customer who already have orders"));
|
||||
}
|
||||
|
||||
$customer->delete();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user