Ajax Email

This article describes all the methods available within the "Email" family of Ajax methods.

Ajax Method Group: Ajax_Email

emailSignup

Overview

Permission Required: None

Method Call: /ajax/Ajax_Email/emailSignup

Response Format: JSON Encoded

Aurora Demo Example: https://demo.auroracommerce.com/

📘

This method allows you to signup email address to the newsletter list.

Method Description

Method specific parameters

ParameterValuesDescriptionRequired
email_firstnamestringFirst name of a user.No
email_lastnamestringLast name of a user.No
email_signupstring, correct email syntax requiredEmail address of a user.Yes
email_listintID which can be used in conjunction with custom newsletter integrations like MailChimp.No
opt_outint, 1 or 0 (default)Opt Out flag.No
email_dob_daystring, valid day number, range 01-31Day of user's date of birth.No
email_dob_monthstring, valid month number, range 01-12Month of user's date of birth.Yes, If email_dob_day provided
email_dob_yearstring, valid year number, e.g.1990Year of user's date of birth.Yes, If email_dob_day provided
custom_fieldsquery string, e.g. k1=v1&k2=v2List of additional data to store against newly created newsletter user.

Please contact your Account Manager to get a list of possible keys
No
output_typestring, 'raw' or 'html'Type of output.

"raw" output provide success flag, messages, and errors in separate containers.
"raw" type is suggested to be used on all integrations.
* "html" type render "generic/ajax-newsletter-signup.tpl.html" and return in single "email_signup_response" container
No
google_recaptchastring, valid Google ReCaptcha responseResponse from Google ReCaptcha user interaction.Yes
update_existingint, 1 or 0 (default)Should existing email subscriptions be updated? If this is not set to 1 and the email address already exists, the request will be rejected as normal.

Where this value is set to 1, and the email address already exists, the following fields will be updated providing they are included within the request:

First name (email_firstname)
Last name (email_firstname)
Date of Birth (email_dob_day, email_dob_month and email_dob_year)
Custom Fields (custom_fields)
No

Response Variables

VariableValuesDescription
email_signup_responseString HTMLRendered "generic/ajax-newsletter-signup.tpl.html" smarty template. Only available on "html" output type.
successBooleanFlag which defines if signup process finished successfully or not. Only available on "raw" output type.
messagesArrayMassages to display to customer. Only available on "raw" output type.

Messages can be managed by below site texts:

Page: 'Newsletter', Part: 'Title: Signup' (on success)
Page: 'Global', Part: 'Warning: Error has occurred' (on failure)
errorsArrayMassages to display to customer. Only available on "raw" output type.
updatedBooleanThis value will indicate whether the request has resulted in a subscription been updated, rather than added.

This will only ever be true where the update_existing parameter has been included within the request and the requested email address already exists.

userExists

❗️

This method must be explicitly enabled here:

Store > Settings > Frontend > Security > Allow email address checking?

Enabling email address checking will allow user email addresses to be checked using unsecured interfaces, which could potentially represent a security risk. By enabling this option, you implicitly acknowledge and automatically assume responsibility for these interfaces.

Aurora email validation processes use Google ReCaptcha to limit the security impact of such interfaces and as such, these can only be enabled if Google ReCaptcha is already enabled.

Overview

Permission Required: Explicitly enabled within store settings and Google ReCaptcha required

Method Call: /ajax/Ajax_Email/userExists

Response Format: JSON Encoded

Aurora Demo Example: https://demo.auroracommerce.com/

📘

This method allows you to check that a user exists based on a given email address.

Method Description

Method specific parameters

ParameterValuesDescriptionRequired
email_addressStringThe email address to check.Yes
google_recaptcha_responseStringThe response from the Google ReCaptcha widget.Yes

Response Variables

VariableValuesDescription
existsBooleanWhether or not the user exists.

This will also be false should an error occur.
newsletter_existsBooleanWhether or not the email address is signed-up to the Aurora Newsletter service.

This will also be false should an error occur.
detailStringA simple message to detail what action was taken or error that may have occurred.

This can be enabled or disabled here:

Store > Settings > Frontend > Security > Return detailed address checking response?

DO NOT enable detailed address checking responses on production sites.

Example Usage

<html>
  <head>
    {include_js files=jquery-1.10.2.min,google_recaptcha}
  </head>
  <body>
    <script type="text/javascript">{literal}
    (function ($) {
      $(document).on('click', '.check_email_button', function () {
        var email_address = $('[name="email_address_check"]').val();
        var google_recaptcha_response = $('#google_recaptcha_email_check').val();
        $.get(
          '/ajax/Ajax_Email/userExists',
          {
            email_address: email_address,
            google_recaptcha_response: google_recaptcha_response
          },
          function(response) {
            console.log(response);
            alert(response.detail);
          },
          'json'
        );
      });
    })(jQuery)
    {/literal}</script><br />
    {google_recaptcha form="user_exists" id="google_recaptcha_email_check" page="login" label=false error=false action="email_exists"}<br />
    <label for="email_address_check">Email address</label><input type="text" name="email_address_check" value="" /><br />
    <a href="#" class="button check_email_button">Check Email</a>
    {google_recaptcha_init form="user_exists"}
  </body>
</html>