diff --git a/core/lib/Thelia/Controller/Front/CustomerController.php b/core/lib/Thelia/Controller/Front/CustomerController.php index 2bb01a94a..7f956287e 100755 --- a/core/lib/Thelia/Controller/Front/CustomerController.php +++ b/core/lib/Thelia/Controller/Front/CustomerController.php @@ -104,6 +104,24 @@ class CustomerController extends BaseFrontController $this->dispatch(TheliaEvents::CUSTOMER_CREATEACCOUNT, $customerCreateEvent); + $newCustomer = $customerCreateEvent->getCustomer(); + + // Newsletter + if (true === $form->get('newsletter')->getData()) { + $newsletterEmail = $newCustomer->getEmail(); + $nlEvent = new NewsletterEvent($newsletterEmail, $this->getRequest()->getSession()->getLang()->getLocale()); + $nlEvent->setFirstname($newCustomer->getFirstname()); + $nlEvent->setLastname($newCustomer->getLastname()); + + // Security : Check if this new Email address already exist + if (null !== $newsletter = NewsletterQuery::create()->findOneByEmail($newsletterEmail)) { + $nlEvent->setId($newsletter->getId()); + $this->dispatch(TheliaEvents::NEWSLETTER_UPDATE, $nlEvent); + } else { + $this->dispatch(TheliaEvents::NEWSLETTER_SUBSCRIBE, $nlEvent); + } + } + $this->processLogin($customerCreateEvent->getCustomer()); $cart = $this->getCart($this->getRequest()); diff --git a/core/lib/Thelia/Form/CustomerCreateForm.php b/core/lib/Thelia/Form/CustomerCreateForm.php index 38da394cc..35954dc88 100755 --- a/core/lib/Thelia/Form/CustomerCreateForm.php +++ b/core/lib/Thelia/Form/CustomerCreateForm.php @@ -89,6 +89,14 @@ class CustomerCreateForm extends AddressCreateForm "for" => "password_confirmation" ) )) + // Add Newsletter + ->add("newsletter", "checkbox", array( + "label" => Translator::getInstance()->trans('I would like to receive the newsletter or the latest news.'), + "label_attr" => array( + "for" => "newsletter" + ), + "required" => false + )) // Add terms & conditions ->add("agreed", "checkbox", array( "constraints" => array( diff --git a/core/lib/Thelia/Form/CustomerProfileUpdateForm.php b/core/lib/Thelia/Form/CustomerProfileUpdateForm.php index c7ebd2c43..3bf0c372a 100755 --- a/core/lib/Thelia/Form/CustomerProfileUpdateForm.php +++ b/core/lib/Thelia/Form/CustomerProfileUpdateForm.php @@ -55,16 +55,7 @@ class CustomerProfileUpdateForm extends CustomerCreateForm ->remove("password") ->remove("password_confirm") // Remove Terms & conditions - ->remove("agreed") - - // Add Newsletter - ->add("newsletter", "checkbox", array( - "label" => Translator::getInstance()->trans('I would like to receive the newsletter or the latest news.'), - "label_attr" => array( - "for" => "newsletter" - ), - "required" => false - )); + ->remove("agreed"); } /** diff --git a/core/lib/Thelia/Form/NewsletterForm.php b/core/lib/Thelia/Form/NewsletterForm.php index ad0aab5a4..2dc910c1d 100644 --- a/core/lib/Thelia/Form/NewsletterForm.php +++ b/core/lib/Thelia/Form/NewsletterForm.php @@ -83,7 +83,7 @@ class NewsletterForm extends BaseForm { $customer = NewsletterQuery::create()->findOneByEmail($value); if ($customer) { - $context->addViolation("You are already subscribed!"); + $context->addViolation("You are already registered!"); } } diff --git a/templates/admin/default/I18n/fr_FR.php b/templates/admin/default/I18n/fr_FR.php index 2de503905..edccca64e 100755 --- a/templates/admin/default/I18n/fr_FR.php +++ b/templates/admin/default/I18n/fr_FR.php @@ -79,7 +79,7 @@ return array ( 'Address Line 2' => 'Adresse suite', 'Additional address' => 'Adresse complémentaire', 'Address Line 3' => 'Adresse suite', - 'Zip code' => 'Code posta', + 'Zip code' => 'Code postal', 'City' => 'Ville', 'Country' => 'Pays', 'Email Address' => 'Adresse e-mail', diff --git a/templates/default/I18n/fr_FR.php b/templates/default/I18n/fr_FR.php index 2aaec2b6e..82a4581c4 100755 --- a/templates/default/I18n/fr_FR.php +++ b/templates/default/I18n/fr_FR.php @@ -148,7 +148,7 @@ return array( 'Rating' => 'Avis', 'Ref.' => '', 'Register!' => 'S\'inscrire !', - 'Register' => 'Se connecter', + 'Register' => 'S\'inscrire', 'Regular Price:' => 'Prix :', 'Related' => 'Liés', // voir le contexte pour l'accord 'Remove this address' => 'Supprimer cette adresse', @@ -165,7 +165,7 @@ return array( 'Send' => 'Envoyer', 'Shipping Tax' => 'Frais de livraison', 'Show' => 'Voir', - 'Sign In' => 'S\'inscrire', + 'Sign In' => 'Se connecter', 'Sign up to receive our latest news.' => 'Inscrivez-vous pour recevoir nos actualités.', 'Skip to content' => 'Aller au contenu', 'Sort By' => 'Trier par', diff --git a/templates/default/account.html b/templates/default/account.html index 639ea25a2..73da05a66 100644 --- a/templates/default/account.html +++ b/templates/default/account.html @@ -156,7 +156,7 @@