Skip to the content

Magento plugin How-To

Our plugin for Magento supports the following features:

  • PredictiveAddress
  • Postcode Lookup
  • Phone Validation
  • Email Validation
  • Name Validation

Magento Plugin Compatibility

Our Magento plugin applies real-time validation to forms across your site.

The following versions have been tested for compatibility:

Magento
2.1.16
2.2.7
2.3.0
2.3.1
2.3.4
2.3.5
2.4.1
2.4.2

Installation

To install the Data8 Magento plugin on your site, search the Magento Marketplace for 'data8' and follow the installation wizard after completing the free checkout. Once installed, you can access the settings page for the plugin from the left-side menu by clicking 'Stores' > 'Configuration' > 'Data8' > 'Data Capture & Validation Settings'.

Should you ever wish to uninstall the Data8 Magento Plugin, from the left side menu click '' and then 'Module Manager'. From here you will see a list of all installed modules. You can disable or delete the Data8 plugin to remove it from your site.

Configuration

From the Data8 settings page (Stores > Configuration > Data8 > Data Capture & Validation) you can enable and choose the validation options that suit your needs.

Settings

On the configuration screen, enter your client-side API key found on your Data8 Dashboard. Each validation service requires the necessary credits to function.


If you are using the PredictiveAddress service, please note that the 'county' property of the address is often not populated in the response as it isn't actually required by the Royal Mail and isn't always possible to retrieve. Therefore, it is recommended that you either remove the county field from your forms, or make sure the county field is not required.

PredictiveAddress Options

When the PredictiveAddress service is enabled, the PredictiveAddress Options box will become visible. This box can be left blank to use the default configuration of PredictiveAddress. However, should you wish to customise your integration, you can do so by entering any combination of the options available for the PredictiveAddress service.

For example, enter the following into the PredictiveAddress options box to detect the initial country in the PredictiveAddress search, from the users IP address:

initialCountry: auto

PredictiveAddress  ///what3words integration

You can search for any 3 word address by simply typing out the three words like so "pitch.tells.civil".

what3words Address

If you wish to store the 3 word address that was used to retrieve the final address, add the class data8_what3words to an input field to indicate where we should store the what3words address.

what3words Location
If you wish to use what3words to get a more precise latitude and longitude, you will need to pass in the options:
includeLocation: true
includeWhat3Words: true

and then add the classes: data8_latitude and data8_longitude to some text inputs to indicate where to store the returned data.


Usage

After entering your configuration details and clicking save, the relevant enhanced data capture and validation will be applied to various data entry points around your site, including:

  • Checkout - Email Validation, Phone Validation, Postcode Lookup, PredictiveAddress
  • Creating a new account - Email Validation
  • Editing account information - Email Validation
  • Adding/editing address book entries - Phone Validation, Postcode Lookup, PredictiveAddress
  • Newsletter subscriptions - Email Validation

Validation can also be applied to custom forms or fields. The following rules can be used to attach Data8 Validation to acceptable fields:

  • Email: Either a field name attribute containing email or a text input of type email.
  • Telephone: Either a field name attribute containing phone or a text input of type tel.
  • Name: A field name attribute containing name, firstname or lastname (excluding username).
  • Address (PredictiveAddress and Postcode Lookup): Fields must use the below structure.
company: id and name = "company"
street 1: id and name = "street_1"
street 2: id and name = "street_2"
city: id and name = "city"
county: id and name = "region"
postcode: id and name = "zip"

Postcode Lookup

When Postcode Lookup is enabled, a button will appear next to postcode fields, which allows users to enter a postcode and then view available results, which makes entering addresses quick and easy.

PredictiveAddress

When PredictiveAddress is enabled, any suitable address entry section on your forms will have use of our address autocomplete and verification tool. Simply begin typing an address/postcode/company name into the Address line 1 box to start searching and narrowing down results.

PredictiveAddress

Validation

If entered data is identified as invalid, the error will be highlighted suitably on the form.

When Phone Validation is enabled, all suitable telephone number fields are validated automatically. The Default Country Code option can be used to specify the ISO 2-character country code or international dialling code of the country to validate the telephone number in, unless the telephone number contains an explicit country code prefix.

When Email Validation is enabled, all suitable email address fields are validated automatically. The level of validation to apply to entered email addresses can be selected from a drop down on the settings page. See the table below for information on each level.

Email Validation Levels:

Level Description
Syntax The supplied email is checked to ensure that it meets the standard email address format. This is the quickest option and would reject such incorrect email addresses as "noone@nowhere" and "N/A", but would accept incorrect email addresses that are correctly formed but that do not include a valid domain name such as "noone@data-9.com".
Domain The supplied email is checked to ensure that the domain name (the part to the right of the @ sign) exists and is set up to receive email. This is still normally very quick, but can take a few seconds in some cases. This check would reject incorrectly formatted email addresses in the same way as the Syntax check, and would also reject a misspelled domain name such as "noone@data-9.com". It can also detect when a domain name exists but does not handle email, such as "noone@example.com". It does not verify that the part of the email address to the left of the @ sign exists.
Server In addition to the Domain level checks, validates that at least one of the mail servers advertised for the domain is actually live.
Address In addition to the Server level checks, validates that the mail server accepts mail for the full email address.

When Name Validation is enabled, all suitable name fields are validated automatically.

Validation