Bonjour,
je voudrais faire un override pour que lorsqu'un client s'inscrit le compte soit en désactivé par défaut.
Voici ce que j'ai fait, mais ça ne marche pas, j'ai juste rajouté la ligne :
$customer->active = false;
<?php use PrestaShop\PrestaShop\Core\Crypto\Hashing as Crypto; use Symfony\Component\Translation\TranslatorInterface; class CustomerPersister extends CustomerPersisterCore { private $errors = []; private $context; private $crypto; private $translator; private $guest_allowed; public function __construct( Context $context, Crypto $crypto, TranslatorInterface $translator, $guest_allowed ) { parent::__construct($context, $crypto, $translator, $guest_allowed); $this->context = $context; $this->crypto = $crypto; $this->translator = $translator; $this->guest_allowed = $guest_allowed; } public function getErrors() { return parent::getErrors(); } public function save(Customer $customer, $clearTextPassword, $newPassword = '', $passwordRequired = true) { return parent::save($customer, $clearTextPassword, $newPassword, $passwordRequired); } private function update(Customer $customer, $clearTextPassword, $newPassword, $passwordRequired = true) { return parent::update($customer, $clearTextPassword, $newPassword, $passwordRequired); } private function create(Customer $customer, $clearTextPassword) { if (!$clearTextPassword) { if (!$this->guest_allowed) { $this->errors['password'][] = $this->translator->trans( 'Password is required', [], 'Shop.Notifications.Error' ); return false; } $clearTextPassword = $this->crypto->hash( microtime(), _COOKIE_KEY_ ); $customer->is_guest = true; } $customer->passwd = $this->crypto->hash( $clearTextPassword, _COOKIE_KEY_ ); if (Customer::customerExists($customer->email, false, true)) { $this->errors['email'][] = $this->translator->trans( 'An account was already registered with this email address', [], 'Shop.Notifications.Error' ); return false; } // Modification : Définir active avant l'appel à la méthode save de l'objet Customer $customer->active = false; $ok = $customer->save(); if ($ok) { $this->context->updateCustomer($customer); $this->context->cart->update(); $this->sendConfirmationMail($customer); Hook::exec('actionCustomerAccountAdd', [ 'newCustomer' => $customer, ]); } return $ok; } private function sendConfirmationMail(Customer $customer) { return parent::sendConfirmationMail($customer); } }
je voudrais également revenir sur la page d'inscription, ou une autre pour informer qu'il faut attendre la validation du compte.
Merci d'avance