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
Parameter | Values | Description | Required |
---|---|---|---|
email_firstname | string | First name of a user. | No |
email_lastname | string | Last name of a user. | No |
email_signup | string, correct email syntax required | Email address of a user. | Yes |
email_list | int | ID which can be used in conjunction with custom newsletter integrations like MailChimp. | No |
opt_out | int, 1 or 0 (default) | Opt Out flag. | No |
email_dob_day | string, valid day number, range 01-31 | Day of user's date of birth. | No |
email_dob_month | string, valid month number, range 01-12 | Month of user's date of birth. | Yes, If email_dob_day provided |
email_dob_year | string, valid year number, e.g.1990 | Year of user's date of birth. | Yes, If email_dob_day provided |
custom_fields | query string, e.g. k1=v1&k2=v2 | List of additional data to store against newly created newsletter user. Please contact your Account Manager to get a list of possible keys | No |
output_type | string, '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_recaptcha | string, valid Google ReCaptcha response | Response from Google ReCaptcha user interaction. | Yes |
update_existing | int, 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
Variable | Values | Description |
---|---|---|
email_signup_response | String HTML | Rendered "generic/ajax-newsletter-signup.tpl.html" smarty template. Only available on "html" output type. |
success | Boolean | Flag which defines if signup process finished successfully or not. Only available on "raw" output type. |
messages | Array | Massages 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) |
errors | Array | Massages to display to customer. Only available on "raw" output type. |
updated | Boolean | This 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
Parameter | Values | Description | Required |
---|---|---|---|
email_address | String | The email address to check. | Yes |
google_recaptcha_response | String | The response from the Google ReCaptcha widget. | Yes |
Response Variables
Variable | Values | Description |
---|---|---|
exists | Boolean | Whether or not the user exists. This will also be false should an error occur. |
newsletter_exists | Boolean | Whether or not the email address is signed-up to the Aurora Newsletter service. This will also be false should an error occur. |
detail | String | A 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>
Updated over 2 years ago