Tutorials | what3words
All tutorials

Installing the Magento 2 extension

intermediate

The what3words Magento 2 extension allows you to add a 3 word address field to a checkout page. Store users can then add a 3 word address to orders and are provided 3 word address suggestions as they type. The user can also save 3 word addresses to their account for future use.

You will need a what3words API key to complete this tutorial.

2

Installation

The Magento 2 Extension can be installed using Composer and Packagist or alternatively installed manually by downloading from Github and adding to your server via FTP or by performing a manual extension installation.

We recommend using Composer and Packagist to install the Extension to ensure that all dependencies are installed along with the Extension.

To add the what3words Magento 2 Extension to a store using composer and packagist, first connect to your server and start the command line interface.

From the CLI run the composer command to install the files and dependencies required by the extension:

composer require what3words/module-what3words
Copied

Next, to compile the site to ensure it includes the new extension run the following commands (as with any other Magento module):

php bin/magento deploy:mode:set --skip-compilation production
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy # here set the themes to be compiled and the language
php bin/magento maintenance:enable
php bin/magento setup:upgrade --keep-generated
php bin/magento maintenance:disable
Copied

We also recommend running php bin/magento cache:clean and php bin/magento cache:flush to ensure the site cache is cleared.

3

Enable module

Select the store settings and a new category “what3words” will be available.

Within the configuration page add the API Key.

We also recommend using a placeholder text with an example 3 word address to demonstrate to users. For example, “eg. filled.count.soap”

A new field will then be available on the site’s checkout page.

4

Add what3words address to the Address template

In order for the what3words address to appear on invoices and labels etc then the what3words address needs to be added to the address template:

“Stores” -> “Configuration” ->”Customers” ->”Customer Configuration” -> “Address Templates”

Add the following to each of the templates:

Text: {{if w3w}}{{var w3w}}{{/if}}

Text One Line: {{var w3w}}

HTML: {{if w3w}}{{var w3w}}{{/if}}

PDF: {{if w3w}}{{var w3w}}{{/if}}|

Related tutorials

Back to top