osCommerce Integration Guide

Integration with osCommerce address forms made simple

Visit the download page  

A step-by-step guide to integration with osCommerce address forms.

Preparation

Download

Download our osCommerce plugin from the plugins page. For osCommerce, we only offer a plugin for Postcode Lookup (UK only). The plugin is free to download.

Sign Up

Next, you need to sign up for a Crafty Clicks account.

When you sign up, you will receive an access token by email. There is no obligation to buy anything and you automatically get 100 trial lookups. If you need more lookups to test the integration, please get in touch (support@craftyclicks.co.uk) and we will try to accommodate you.

Installation

Step 1

Paste your access token in place of xxxxx-xxxxx-xxxxx-xxxxx at the top of the file crafty_html_output.php.

Step 2

Copy the following files to your server:

catalog/ext/craftyclicks/crafty_html_output.php catalog/ext/craftyclicks/crafty_postcode_busy.gif catalog/ext/craftyclicks/crafty_postcode.class.js catalog/ext/craftyclicks/button_find_address.gif

Step 3

You will need to modify these files:

catalog/address_book_process.php catalog/checkout_payment_address.php catalog/checkout_shipping_address.php catalog/create_account.php

catalog/includes/modules/address_book_details.php catalog/includes/modules/checkout_new_address.php

catalog/admin/customers.php

Step 4

In file catalog/address_book_process.php

FIND (around line 250)

require(DIR_WS_INCLUDES . 'template_top.php');

INSERT AFTER:

require('ext/craftyclicks/crafty_html_output.php');
echo tep_crafty_script_add('addressbook');

Step 5

In file catalog/checkout_payment_address.php

FIND (around line 197)

require(DIR_WS_INCLUDES . 'template_top.php');

INSERT AFTER:

require('ext/craftyclicks/crafty_html_output.php');
echo tep_crafty_script_add('checkout_address');

Step 6

In file catalog/checkout_shipping_address.php

FIND (around line 209)

require(DIR_WS_INCLUDES . 'template_top.php');

INSERT AFTER:

require('ext/craftyclicks/crafty_html_output.php');
echo tep_crafty_script_add('checkout_address');

Step 7

In file catalog/create_account.php

FIND (around line 257)

require(DIR_WS_INCLUDES . 'template_top.php');

INSERT AFTER:

require('ext/craftyclicks/crafty_html_output.php');
echo tep_crafty_script_add('create_account');

FIND (around line 369)

<td class="fieldValue"><?php echo tep_draw_input_field('postcode') . '&nbsp;' . (tep_not_null(ENTRY_POST_CODE_TEXT) ? '<span class="inputRequirement">' . ENTRY_POST_CODE_TEXT . '</span>': ''); ?></td>

INSERT before the last semicolon

. '&nbsp;&nbsp;' . tep_crafty_button()

THE RESULT SHOULD BE

<td class="fieldValue"><?php echo tep_draw_input_field('postcode') . '&nbsp;' . (tep_not_null(ENTRY_POST_CODE_TEXT) ? '<span class="inputRequirement">' . ENTRY_POST_CODE_TEXT . '</span>': ''). '&nbsp;&nbsp;' . tep_crafty_button(); ?></td>

FIND (just below around line 370)

</tr>

INSERT AFTER

<tr>
<td class="fieldKey">&nbsp;</td>
<td class="fieldValue" id="crafty_postcode_result_display">&nbsp;</td>
</tr>

AT THE BOTTOM OF THE FILE ADD

<?php echo tep_crafty_country_handler(); ?>

Step 8

In file catalog/includes/modules/address_book_details.php

FIND (around line 87)

<td class="fieldValue"><?php echo tep_draw_input_field('postcode', (isset($entry['entry_postcode']) ? $entry['entry_postcode'] : '')) . '&nbsp;' . (tep_not_null(ENTRY_POST_CODE_TEXT) ? '<span class="inputRequirement">' . ENTRY_POST_CODE_TEXT . '</span>': ''); ?></td>

INSERT before the last semicolon

. '&nbsp;&nbsp;' . tep_crafty_button()

THE RESULT SHOULD BE

<td class="fieldValue"><?php echo tep_draw_input_field('postcode', (isset($entry['entry_postcode']) ? $entry['entry_postcode'] : '')) . '&nbsp;' . (tep_not_null(ENTRY_POST_CODE_TEXT) ? '<span class="inputRequirement">' . ENTRY_POST_CODE_TEXT . '</span>': ''). '&nbsp;&nbsp;' . tep_crafty_button();; ?></td>

FIND (just below, around line 88)

</tr>

INSERT AFTER

<tr>
<td class="fieldKey">&nbsp;</td>
<td class="fieldValue" id="crafty_postcode_result_display">&nbsp;</td>
</tr>

AT THE BOTTOM OF THE FILE ADD

<?php echo tep_crafty_country_handler(); ?>

Step 9

In file catalog/includes/modules/checkout_new_address.php

FIND (around line 81)

<td class="fieldValue"><?php echo tep_draw_input_field('postcode') . '&nbsp;' . (tep_not_null(ENTRY_POST_CODE_TEXT) ? '<span class="inputRequirement">' . ENTRY_POST_CODE_TEXT . '</span>': ''); ?></td>

INSERT before the last semicolon

. '&nbsp;&nbsp;' . tep_crafty_button()

THE RESULT SHOULD BE

<td class="fieldValue"><?php echo tep_draw_input_field('postcode') . '&nbsp;' . (tep_not_null(ENTRY_POST_CODE_TEXT) ? '<span class="inputRequirement">' . ENTRY_POST_CODE_TEXT . '</span>': ''). '&nbsp;&nbsp;' . tep_crafty_button(); ?></td>

FIND (just below, around line 82)

</tr>

INSERT AFTER

<tr>
<td class="fieldKey">&nbsp;</td>
<td class="fieldValue" id="crafty_postcode_result_display">&nbsp;</td>
</tr>

AT THE BOTTOM OF THE FILE ADD

<?php echo tep_crafty_country_handler(); ?>

Step 10

In file catalog/admin/customers.php

FIND (around line 230)

require(DIR_WS_INCLUDES . 'template_top.php');

INSERT AFTER:

require('../ext/craftyclicks/crafty_html_output.php');
echo tep_crafty_script_add('customers',1,true);

FIND (around line 555)

} else {
echo tep_draw_input_field('entry_postcode', $cInfo->entry_postcode, 'maxlength="8"', true);
}
?></td>

INSERT before the ?>

echo '&nbsp;&nbsp;' . tep_crafty_button();

INSERT after the </tr>

<tr>
<td class="main">&nbsp;</td>
<td class="main" id="crafty_postcode_result_display">&nbsp;</td>
</tr>

THE RESULT SHOULD BE

} else {
echo tep_draw_input_field('entry_postcode', $cInfo->entry_postcode, 'maxlength="8"', true);
}
echo '&nbsp;&nbsp;' . tep_crafty_button();?></td>
</tr>
<tr>
<td class="main">&nbsp;</td>
<td class="main" id="crafty_postcode_result_display">&nbsp;</td>
</tr>

AT THE BOTTOM OF THE FILE ADD

<?php echo tep_crafty_country_handler(); ?>

Step 11 (optional)

Play around with configuration options near the top of file catalog/ext/craftyclicks/crafty_html_output.php.

On line 4: set CP_ADDRESS_LOOKUP_BUTTON_STYLE = 1 for a graphical button, or = 0 for a plain browser generated button. Or modify the html in function tep_crafty_button_add() to make up your own flavour.

Step 12 (optional)

To leave the county out, simply remove the field in your html. If you want to keep the field, but want to prevent CraftyPostcode from populating it, go to lines 9 and change the define CP_COUNTY_NAME to 2.

If you prefer to use county names we provide two options: Traditional County Name and Postal County Name. To get the traditional county name set CP_COUNTY_NAME to 1. To go for the Royal Mail postal county name set it to 0 (default).

Step 13 (optional)

Make UK the default country. If you set the CP_HIDE_ADDRESS_LOOKUP_FOR_NON_UK_COUNTRY config to 1, the ‘find address’ button will be visible only if country is UK.

In includes/functions/html_output.php on or around line 318:

Look for:

function tep_get_country_list($name, $selected = '', $parameters = '') {

Change to:

function tep_get_country_list($name, $selected = '222', $parameters = '') {

Step 14 (optional)

Add more UK country options. Some people like to split the UK into Channel Islands, Scottish Highlands, etc. to help with shipping calculations and/or to treat them differently for VAT.

To do that add more countries into the ‘countries’ MySQL table first (you may have done this already). Next add the new country ids into the $cp_uk_country_ids array near the top of crafty_html_output.php.

The default array is:

$cp_uk_country_ids = Array(222);

Change it to something like this (substitute your own ids for 240 and 241):

$cp_uk_country_ids = Array(222, 240, 241);

You may want to auto-detect the country based on postcode entered. Set CP_DETECT_COUNTRY_FROM_POSTCODE to 1.

Then set your config in this array. For example if ‘Channel Islands is country code 240:

$cp_postcode_to_country_map = Array('GY' => 240, 'JE' => 240);

If the user enters a postcode starting with GE, or JE the country selected will change to ‘Channel Islands’.

Step 15 (optional)

You can enable searching by house name/number – change CP_ENABLE_SEARCH_BY_HOUSE_NAME_NUMBER to 1. When this is enabled an extra input field is used above postcode on the front end. Visitors can enter their house name or number and the drop-down list is shown only if more than one match is found. This can save having to open up the drop down to find your address.

To get this to work, in files create_account.php, address_book_details.php and checkout_new_address.php you need to add the house name/number form field. If you copied the files contained in this package, you are all done. If you modified your own files :

FIND

<tr>
<td class="fieldKey"><?php echo ENTRY_POST_CODE; ?></td>

INSERT BEFORE:

<?php
if (1 == CP_ENABLE_SEARCH_BY_HOUSE_NAME_NUMBER) {
?>
<tr>
<td class="fieldKey"><?php echo 'House Name/Number:'; ?></td>
<td class="fieldValue"><?php echo tep_draw_input_field('cp_house_name_number_in') ?></td>
</tr>
<?php
}
?>

Step 16 (optional)

You can hide most of the address lines until the user has looked up a postcode. This can give you a cleaner, shorter form. Once the address selection box appears the hidden address lines are shown to allow address editting if needed. On lookup error or if a non-UK country is selected the address lines will also be shown.

To get this to work set CP_HIDE_ADDRESS_FIELDS_BEFORE_LOOKUP to 1. Then you need to attach a unique class to all element in your form that you want to hide. By default this class is cp_hide_it.

NOTE: <td> and <tr> elements can’t be hidden (they don’t have the display style property). Best way around this is to wrap all <td> content in a <div>, e.g.:

<td class="main"><div class="cp_hide_it"> .... .... </div></td>

FAQ

Test

Before you go live, test the integration to make sure it is working properly.

For the Postcode Lookup integration only, we have the following free postcodes for testing: AA1 1AA, AA1 1AB, AA1 1AD and AA1 1AE.

If you need assistance, drop us an email on support@craftyclicks.co.uk – we will help!

Go Live

Once your trial lookups run out, you will need to decide on the best purchasing option based on the volume of usage you expect on your site. If you would like us to advise you then please get in touch.

Questions

  • Do you offer support? Yes, we do offer support during normal business hours in the UK. If you run into any issues, let us know and we will be happy to help.
  • Is this free? The extension is free to download and try, but to use it on a live site you will need a paid account with us.
  • Do I need to sign up for an account to try it? Yes, you’ll need a trial account, at least. You can easily sign up for a free trial account.
Last Updated: 4/1/2019, 1:32:39 PM