Double Opt-In for Registration and Newsletter

The KonaKart storefront application can be configured to require double opt-in when a customer registers and when a customer signs up for the newsletter.

Double opt-in can be enabled by setting the following configuration variables under Configuration >> Store Configuration.

The base URL used to construct the link in the email that the customer clicks on is read from the Store Base URL configuration variable which can also be found under Configuration >> Store Configuration.

Customer Registration

The code that sends the email containing the double opt-in link is in CustomerRegistrationSubmitAction.java. The Velocity template is called RegistrationDoubleOptIn. The customer is registered but left disabled and the emailVerified attribute is set to false.

When the user clicks on the link in the email, the code in EnableCustomerSubmitAction is run which enables the previously registered customer and notifies the user that this has happened and the account is now fully functional.

If the link in the email is never clicked, the registered customer object remains in the KonaKart database in a disabled state with emailVerified set to false. If the user were to try and register again, the KonaKart engine detects that double opt-in is enabled and that a customer exists which has never been activated and so allows the new registration to override the previous one.

A difference in the double opt-in mechanism compared to not using double opt-in for registration is that normally, customer tags and maybe reward points are set immediately after registering and logging in the customer. In the case of double opt-in, the customer is registered in a disabled state and so tags may not be set until the customer is enabled and logs in to the system. At login time you could detect that certain tag values are missing and set them just after the customer logs in.

Newsletter Subscription

The code that sends the email containing the double opt-in link is in SubscribeNewsletterSubmitAction.java. The Velocity template is called NewsletterDoubleOptIn.

When the user clicks on the link in the email, the code in SubscribeNewsletterConfirmSubmitAction is run which calls the KonaKart engine to set the newsletter attribute on the customer object.