2

In Checkout page, there's a checkbox that allows guests to subscribe to Newsletter by placing their order.

But there is no control over already subscribed emails. If guest's email is already included in newsletter subscribers list, guest receives the "Thank you for your Newsletter Subscription" email again.

Is there a way to display an error message in checkout page or even hide the newsletter checkbox, in case the customer's email is already included in newsletter subscribers?

1

Check if the guest customer has subscribed to the newsletter from checkout page by using event observer. You may need to create a Custom module

Use this event:

<newsletter_subscriber_save_after>
  <observers>
    <namespace_module_model_observer>
      <class>Namespace_Module_Model_Observer</class>
      <method>subscribedToNewslettercheck</method>
    </namespace_module_model_observer>
  </observers>
</newsletter_subscriber_save_after>

In Observer file you can check like this way

class Namespace_Module_Model_Observer {
        public function subscribedToNewslettercheck(Varien_Event_Observer $observer)
    {
        $event = $observer->getEvent();
        $subscriber = $event->getDataObject();
        $data = $subscriber->getData();
        $email = $data['subscriber_email'];


        $statusChange = $subscriber->getIsStatusChanged();
        if ($data['subscriber_status'] == "1" && $statusChange == true) {
                        //code to handle if customer is just subscribed...
                }
        }
}
  • after testing this, it seems that it's always executed, even if the custom has not checked the "subscribe to newsletter" checkbox. Could you check that please? – zekia Jan 11 '18 at 11:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.