Sloppy Address Cleaner

Table of Contents

Download

Address cleaner is available from the opencart market place here: Sloppy Address Cleaner.

A full list of my extensions is availble here: Opencart Market Place

New Installation - Opencart 3.x

  1. Go to Extensions -> Installer
  2. Upload the file address_cleaner_oc3x_plus_journal.ocmod.zip and wait for it to finish
  3. Go to System -> Users -> User Groups, edit admin user and select:
    extension/module/address_cleaner
  4. Go to Extensions -> Modifications and click on the 'Refresh' button top right.
  5. Go to Extensions -> Extensions, select 'Modules' and install the Address Cleaner module.
  6. Edit the Address Cleaner Module.
    1. the default settings should already be installed for you.
    2. Alter the settings to suit your needs - see below.

New Installation - Opencart 1.5.x to 2.3.x

  1. Check and edit if necessarythe settings in the file ../upload/system/helper/address_cleaner.php.  See Settings and Information sections below for more details.
  2. Upload the contents of the upload folder to your server via FTP.
  3. Test and enjoy!

Settings

Setting can be found in the Address Cleaner Module (Admin -> Extensions -> Extensions).

I have set up the extension to cover most things so for standard addresses you should not need to make many, if any at all, adjustments.

It is a little complex and does do essentially the same job two or three times, but that allows you to adjust the lists as necessary to suit the data that your country/customers enter. That is why there are multiple lists, if you don't get it right with one list, you can use a different list to try and catch it.

  • Main Corrections List
    This works on all fields.  They should be entered as you want them - As all CAPITALS or LOWERCASE
  • Delimiters
    Delimiters are characters or words that are used to break the input into parts to allow the cleaning function to work on the individual words.  The most common delimiter is a SPACE, but also comma, apostrophe etc. and some words like Mac for names.  Enter any words with a capital letter at the front.
  • Upper Case - Names
    A pipe (|) seperated list of words that you want in all uppercase. Enter the words with a capital letter at the front. Works on name fields only.
  • Lower Case - Names
    A pipe (|) seperated list of words that you want in all lowercase. Enter the words with a capital letter at the front. Works on name fields only.
  • Upper Case - Address
    A pipe (|) seperated list of words that you want in all uppercase. Enter the words with a capital letter at the front. Works on all fields except the name fields.
  • Lower Case - Address
    A pipe (|) seperated list of words that you want in all lowercase. Enter the words with a capital letter at the front. Works on all fields except the name fields.
  • Prefix Corrections
    If you have an issue with a common miscorrection with a delimter, you can fix it here.  An expample is MacIntire which should be Macintire.

Information

Information is passed to the address cleaner function in the form of:

cleanaddress($this->db->escape($data['firstname']), true)

- or -

cleanaddress($this->db->escape($data['address_1']))

the true part is telling the function the the information is a Name, for non-name fields, just leave the true off like the second line above.

SO, if we do this in the address cleaner function:

if ($is_name) {
  $all_uppercase = 'Andrew|John|Fred';
  $all_lowercase = 'De La|De Las|De|Der|Or|And';
} else {

This means that if someone types  'andrew' or 'Andrew' into the name field it will be converted into ANDREW.
If they type fred then it will become FRED.
Likewise, if they type 'DE LAs' into the name field it will convert it to 'de las'.

You'll notice that the beginning of the exceptions start with capitals, that is because they have been capitalised already by the function and the exceptions kick in afterwards to clean it up.

So, if you want to add a word(s) in the exceptions list it must be entered in title case (capital letter at the beginning of every word).

Notes

As this affects the checkout, you should run a test order or two to check that it is working OK.