UK_Postcode_Address_Finder - Version 1.5.0

Version Notes

Release History :
v 1.5.0
* add config option for 1st result line.
* avoid using JavaScript DOM for modifying address forms - it was conflicting with Magento JavaScript.
We now edit the template .phtml files directly.
* fix problems with re-displaying state select box when country is changed from UK to USA.
* fix problem with postcode error message affecting button position if form was submitted with a blank postcode.

v 1.4.0
* make error message class configurable - it can now be styled to match other Magento errors
* make error message text configurable
* fix issue with error message not being shown if hiding of address fields was enabled

v 1.3.0
* populate the company field if company name is available
* unhide all address lines on lookup error to allow customer to enter the address manually
* update to latest CraftyClicks JavaScript (v3.5):
- added the on_error event
- fixed selection of result using keyboard (got broken in latest Firefox v3.5)

v 1.2.0
* can now hide the region/province (county) field
* update to latest CraftyClicks JavaScript (v3.4)

v 1.1.2 (bug fix release)
* fix typo in JS code

v 1.1.1 (bug fix release)
* fix rearranging address fields order; was causing problems on one page checkout
* fix hiding of result box on result select
* hide result box on country change

v 1.1.0
* added Admin Panel options to configure look and feel of the module
* add address lookup to multiship checkout pages

v 1.0.0 - Initial Release

Download this release

Release Info

Developer Magento Core Team
Extension UK_Postcode_Address_Finder
Version 1.5.0
Comparing to
See all releases


Code changes from version 1.4.0 to 1.5.0

app/code/local/Dnc/Craftyclicks/etc/config.xml CHANGED
@@ -12,7 +12,7 @@
12
  <config>
13
  <modules>
14
  <Dnc_Craftyclicks>
15
- <version>1.4.0</version>
16
  </Dnc_Craftyclicks>
17
  </modules>
18
 
@@ -40,14 +40,13 @@
40
  <active>0</active>
41
  <model>dnc/craftyclicks</model>
42
  <access_token>xxxxx-xxxxx-xxxxx-xxxxx</access_token>
43
- <add_elements>1</add_elements>
44
  <button_image></button_image>
45
  <button_class>form-button-alt</button_class>
46
- <change_fields>1</change_fields>
47
  <hide_fields>0</hide_fields>
48
  <hide_county>1</hide_county>
49
  <clear_result>0</clear_result>
50
  <error_class>error</error_class>
 
51
  <error_msg_1>This postcode could not be found, please try again or enter your address manually</error_msg_1>
52
  <error_msg_2>This postcode is not valid, please try again or enter your address manually</error_msg_2>
53
  <error_msg_3>Unable to connect to address lookup server, please enter your address manually</error_msg_3>
12
  <config>
13
  <modules>
14
  <Dnc_Craftyclicks>
15
+ <version>1.5.0</version>
16
  </Dnc_Craftyclicks>
17
  </modules>
18
 
40
  <active>0</active>
41
  <model>dnc/craftyclicks</model>
42
  <access_token>xxxxx-xxxxx-xxxxx-xxxxx</access_token>
 
43
  <button_image></button_image>
44
  <button_class>form-button-alt</button_class>
 
45
  <hide_fields>0</hide_fields>
46
  <hide_county>1</hide_county>
47
  <clear_result>0</clear_result>
48
  <error_class>error</error_class>
49
+ <first_res_line>----- please select your address ----</first_res_line>
50
  <error_msg_1>This postcode could not be found, please try again or enter your address manually</error_msg_1>
51
  <error_msg_2>This postcode is not valid, please try again or enter your address manually</error_msg_2>
52
  <error_msg_3>Unable to connect to address lookup server, please enter your address manually</error_msg_3>
app/code/local/Dnc/Craftyclicks/etc/system.xml CHANGED
@@ -39,17 +39,6 @@
39
  <show_in_store>0</show_in_store>
40
  </access_token>
41
 
42
- <add_elements translate="label">
43
- <label>Generate Button and Results Box</label>
44
- <frontend_type>select</frontend_type>
45
- <source_model>adminhtml/system_config_source_yesno</source_model>
46
- <sort_order>10</sort_order>
47
- <show_in_default>1</show_in_default>
48
- <show_in_website>1</show_in_website>
49
- <show_in_store>0</show_in_store>
50
- <comment>Select to automatically create a 'Find Address' button and a results box using JavaScript DOM. This might not work on some templates. To get more control over the placing/styling you may prefer to modify your template files by hand.</comment>
51
- </add_elements>
52
-
53
  <button_image translate="label">
54
  <label>Button Image</label>
55
  <frontend_type>text</frontend_type>
@@ -57,7 +46,7 @@
57
  <show_in_default>1</show_in_default>
58
  <show_in_website>1</show_in_website>
59
  <show_in_store>0</show_in_store>
60
- <comment>If you set 'Generate Button and Results Box' to 'yes' here you can enter an image file name to use as the 'Find Address' button. Leave blank for a browser default button. Images shoul dbe placed in /craftclicks in you skin folder.</comment>
61
  </button_image>
62
 
63
  <button_class translate="label">
@@ -67,20 +56,9 @@
67
  <show_in_default>1</show_in_default>
68
  <show_in_website>1</show_in_website>
69
  <show_in_store>0</show_in_store>
70
- <comment>If you set 'Generate Button and Results Box' to 'yes' here you can set the css class to use for the 'Find Address' button. Leave blank for a browser default button. Try 'form-button-alt'.</comment>
71
  </button_class>
72
 
73
- <change_fields translate="label">
74
- <label>Change Address Fields Order</label>
75
- <frontend_type>select</frontend_type>
76
- <source_model>adminhtml/system_config_source_yesno</source_model>
77
- <sort_order>15</sort_order>
78
- <show_in_default>1</show_in_default>
79
- <show_in_website>1</show_in_website>
80
- <show_in_store>0</show_in_store>
81
- <comment>Select to have address fields order changed automatically (might not work on some templates). The new order: country, postcode, street, town.</comment>
82
- </change_fields>
83
-
84
  <hide_fields translate="label">
85
  <label>Hide Address Fields for New Address Entry</label>
86
  <frontend_type>select</frontend_type>
@@ -89,7 +67,7 @@
89
  <show_in_default>1</show_in_default>
90
  <show_in_website>1</show_in_website>
91
  <show_in_store>0</show_in_store>
92
- <comment>Select to hide address fields until a postcode is looked up and an address is selected (might not work on some templates). Address fields are only hidden if they are blank (i.e. new address entry, not edit).</comment>
93
  </hide_fields>
94
 
95
  <hide_county translate="label">
@@ -124,6 +102,16 @@
124
  <comment>Set the css class to use for the error messages. Try 'error-msg', 'error' or even leave it blank.</comment>
125
  </error_class>
126
 
 
 
 
 
 
 
 
 
 
 
127
  <error_msg_1 translate="label">
128
  <label>Error Msg #1</label>
129
  <frontend_type>text</frontend_type>
@@ -131,7 +119,7 @@
131
  <show_in_default>1</show_in_default>
132
  <show_in_website>1</show_in_website>
133
  <show_in_store>0</show_in_store>
134
- <comment>This message is shown if the postcode is in valid format, but not found int he database'.</comment>
135
  </error_msg_1>
136
 
137
  <error_msg_2 translate="label">
@@ -141,7 +129,7 @@
141
  <show_in_default>1</show_in_default>
142
  <show_in_website>1</show_in_website>
143
  <show_in_store>0</show_in_store>
144
- <comment>This message is shown if the postcode format is not valid'.</comment>
145
  </error_msg_2>
146
 
147
  <error_msg_3 translate="label">
@@ -151,7 +139,7 @@
151
  <show_in_default>1</show_in_default>
152
  <show_in_website>1</show_in_website>
153
  <show_in_store>0</show_in_store>
154
- <comment>This message is shown if the connection to lookup server times out'.</comment>
155
  </error_msg_3>
156
 
157
  <error_msg_4 translate="label">
@@ -161,7 +149,7 @@
161
  <show_in_default>1</show_in_default>
162
  <show_in_website>1</show_in_website>
163
  <show_in_store>0</show_in_store>
164
- <comment>This message is shown if any other error occurs'.</comment>
165
  </error_msg_4>
166
 
167
  <help_label translate="label">
39
  <show_in_store>0</show_in_store>
40
  </access_token>
41
 
 
 
 
 
 
 
 
 
 
 
 
42
  <button_image translate="label">
43
  <label>Button Image</label>
44
  <frontend_type>text</frontend_type>
46
  <show_in_default>1</show_in_default>
47
  <show_in_website>1</show_in_website>
48
  <show_in_store>0</show_in_store>
49
+ <comment>Here you can enter an image file name to use as the 'Find Address' button. Leave blank for a default Magento button. Images should be placed under /craftclicks in you skin folder.</comment>
50
  </button_image>
51
 
52
  <button_class translate="label">
56
  <show_in_default>1</show_in_default>
57
  <show_in_website>1</show_in_website>
58
  <show_in_store>0</show_in_store>
59
+ <comment>Here you can set the css class to use for the 'Find Address' button. Leave blank for a browser default button. Try 'form-button-alt'.</comment>
60
  </button_class>
61
 
 
 
 
 
 
 
 
 
 
 
 
62
  <hide_fields translate="label">
63
  <label>Hide Address Fields for New Address Entry</label>
64
  <frontend_type>select</frontend_type>
67
  <show_in_default>1</show_in_default>
68
  <show_in_website>1</show_in_website>
69
  <show_in_store>0</show_in_store>
70
+ <comment>Select to hide address fields until a postcode is looked up and an address is selected. Address fields are only hidden if they are blank (i.e. new address entry, not edit).</comment>
71
  </hide_fields>
72
 
73
  <hide_county translate="label">
102
  <comment>Set the css class to use for the error messages. Try 'error-msg', 'error' or even leave it blank.</comment>
103
  </error_class>
104
 
105
+ <first_res_line translate="label">
106
+ <label>First Result Line</label>
107
+ <frontend_type>text</frontend_type>
108
+ <sort_order>33</sort_order>
109
+ <show_in_default>1</show_in_default>
110
+ <show_in_website>1</show_in_website>
111
+ <show_in_store>0</show_in_store>
112
+ <comment>Text to place as first line in the result drop-down box.</comment>
113
+ </first_res_line>
114
+
115
  <error_msg_1 translate="label">
116
  <label>Error Msg #1</label>
117
  <frontend_type>text</frontend_type>
119
  <show_in_default>1</show_in_default>
120
  <show_in_website>1</show_in_website>
121
  <show_in_store>0</show_in_store>
122
+ <comment>This message is shown if the postcode is in valid format, but not found int the database.</comment>
123
  </error_msg_1>
124
 
125
  <error_msg_2 translate="label">
129
  <show_in_default>1</show_in_default>
130
  <show_in_website>1</show_in_website>
131
  <show_in_store>0</show_in_store>
132
+ <comment>This message is shown if the postcode format is not valid.</comment>
133
  </error_msg_2>
134
 
135
  <error_msg_3 translate="label">
139
  <show_in_default>1</show_in_default>
140
  <show_in_website>1</show_in_website>
141
  <show_in_store>0</show_in_store>
142
+ <comment>This message is shown if the connection to lookup server times out.</comment>
143
  </error_msg_3>
144
 
145
  <error_msg_4 translate="label">
149
  <show_in_default>1</show_in_default>
150
  <show_in_website>1</show_in_website>
151
  <show_in_store>0</show_in_store>
152
+ <comment>This message is shown if any other error occurs.</comment>
153
  </error_msg_4>
154
 
155
  <help_label translate="label">
app/design/frontend/default/default/template/dnc/craftyclicks/checkout/onepage/billing.phtml CHANGED
@@ -36,8 +36,7 @@
36
  <li><?php echo $this->getLayout()->createBlock('customer/widget_name')->setObject($this->getAddress())
37
  ->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml() ?></li>
38
  <li>
39
- <?php if (1 != Mage::getStoreConfig('general/craftyclicks/active') ||
40
- 1 != Mage::getStoreConfig('general/craftyclicks/change_fields')) : ?>
41
  <div class="input-box">
42
  <label for="billing:company"><?php echo $this->__('Company') ?></label><br />
43
  <input type="text" id="billing:company" name="billing[company]" value="<?php echo $this->htmlEscape($this->getAddress()->getCompany()) ?>" title="<?php echo $this->__('Company') ?>" class="input-text" /></div>
@@ -48,15 +47,24 @@
48
  <input type="text" name="billing[email]" id="billing:email" value="<?php echo $this->htmlEscape($this->getAddress()->getEmail()) ?>" title="<?php echo $this->__('Email Address') ?>" class="validate-email required-entry input-text" /></div>
49
  <?php endif ?>
50
  </li>
51
- <?php if (1 == Mage::getStoreConfig('general/craftyclicks/active') &&
52
- 1 == Mage::getStoreConfig('general/craftyclicks/change_fields')) : ?>
53
  <li><div class="input-box">
54
  <label for="billing:country_id"><?php echo $this->__('Country') ?> <span class="required">*</span></label><br />
55
  <?php echo $this->getCountryHtmlSelect('billing') ?></div>
56
- <div class="input-box">
57
  <label for="billing:postcode"><?php echo $this->__('Zip/Postal Code') ?> <span class="required">*</span></label><br />
58
  <input type="text" title="<?php echo $this->__('Zip/Postal Code') ?>" name="billing[postcode]" id="billing:postcode" value="<?php echo $this->htmlEscape($this->getAddress()->getPostcode()) ?>" class="validate-zip-international required-entry input-text" /></div>
59
- </li>
 
 
 
 
 
 
 
 
 
 
60
  <li>
61
  <div class="input-box">
62
  <label for="billing:company"><?php echo $this->__('Company') ?></label><br />
@@ -81,8 +89,7 @@
81
  </script>
82
  <input type="text" id="billing:region" name="billing[region]" value="<?php echo $this->htmlEscape($this->getAddress()->getRegion()) ?>" title="<?php echo $this->__('State/Province') ?>" class="input-text" style="display:none" />
83
  </div></li>
84
- <?php if (1 != Mage::getStoreConfig('general/craftyclicks/active') ||
85
- 1 != Mage::getStoreConfig('general/craftyclicks/change_fields')) : ?>
86
  <li><div class="input-box">
87
  <label for="billing:postcode"><?php echo $this->__('Zip/Postal Code') ?> <span class="required">*</span></label><br />
88
  <input type="text" title="<?php echo $this->__('Zip/Postal Code') ?>" name="billing[postcode]" id="billing:postcode" value="<?php echo $this->htmlEscape($this->getAddress()->getPostcode()) ?>" class="validate-zip-international required-entry input-text" /></div>
36
  <li><?php echo $this->getLayout()->createBlock('customer/widget_name')->setObject($this->getAddress())
37
  ->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml() ?></li>
38
  <li>
39
+ <?php if (1 != Mage::getStoreConfig('general/craftyclicks/active')) : ?>
 
40
  <div class="input-box">
41
  <label for="billing:company"><?php echo $this->__('Company') ?></label><br />
42
  <input type="text" id="billing:company" name="billing[company]" value="<?php echo $this->htmlEscape($this->getAddress()->getCompany()) ?>" title="<?php echo $this->__('Company') ?>" class="input-text" /></div>
47
  <input type="text" name="billing[email]" id="billing:email" value="<?php echo $this->htmlEscape($this->getAddress()->getEmail()) ?>" title="<?php echo $this->__('Email Address') ?>" class="validate-email required-entry input-text" /></div>
48
  <?php endif ?>
49
  </li>
50
+ <?php if (1 == Mage::getStoreConfig('general/craftyclicks/active')) : ?>
 
51
  <li><div class="input-box">
52
  <label for="billing:country_id"><?php echo $this->__('Country') ?> <span class="required">*</span></label><br />
53
  <?php echo $this->getCountryHtmlSelect('billing') ?></div>
54
+ <div class="input-box" id="zipDiv">
55
  <label for="billing:postcode"><?php echo $this->__('Zip/Postal Code') ?> <span class="required">*</span></label><br />
56
  <input type="text" title="<?php echo $this->__('Zip/Postal Code') ?>" name="billing[postcode]" id="billing:postcode" value="<?php echo $this->htmlEscape($this->getAddress()->getPostcode()) ?>" class="validate-zip-international required-entry input-text" /></div>
57
+ <div class="input-box" id="findAddrBtnDiv" style="display:none;"><br />
58
+ &nbsp;
59
+ <?php if ('' != Mage::getStoreConfig('general/craftyclicks/button_image')) : ?>
60
+ <img style="cursor: pointer;" src="<?php echo $this->getSkinUrl('craftyclicks/'.Mage::getStoreConfig('general/craftyclicks/button_image')); ?>" onclick="_cp_do_lookup()" title="Find Address" class="<?php echo Mage::getStoreConfig('general/craftyclicks/button_class');?>"/>
61
+ <?php else : ?>
62
+ <button type="button" onclick="_cp_do_lookup()" class="<?php echo Mage::getStoreConfig('general/craftyclicks/button_class');?>">Find Address</button>
63
+ <?php endif ?>
64
+ </div>
65
+ </li>
66
+ <li><span style="display:none;" id="crafty_postcode_result_display">&nbsp;
67
+ </span></li>
68
  <li>
69
  <div class="input-box">
70
  <label for="billing:company"><?php echo $this->__('Company') ?></label><br />
89
  </script>
90
  <input type="text" id="billing:region" name="billing[region]" value="<?php echo $this->htmlEscape($this->getAddress()->getRegion()) ?>" title="<?php echo $this->__('State/Province') ?>" class="input-text" style="display:none" />
91
  </div></li>
92
+ <?php if (1 != Mage::getStoreConfig('general/craftyclicks/active')) : ?>
 
93
  <li><div class="input-box">
94
  <label for="billing:postcode"><?php echo $this->__('Zip/Postal Code') ?> <span class="required">*</span></label><br />
95
  <input type="text" title="<?php echo $this->__('Zip/Postal Code') ?>" name="billing[postcode]" id="billing:postcode" value="<?php echo $this->htmlEscape($this->getAddress()->getPostcode()) ?>" class="validate-zip-international required-entry input-text" /></div>
app/design/frontend/default/default/template/dnc/craftyclicks/checkout/onepage/shipping.phtml CHANGED
@@ -35,8 +35,7 @@
35
  <ul>
36
  <li><?php echo $this->getLayout()->createBlock('customer/widget_name')->setObject($this->getAddress())
37
  ->setFieldIdFormat('shipping:%s')->setFieldNameFormat('shipping[%s]')->setFieldParams('onchange="shipping.setSameAsBilling(false)"')->toHtml() ?></li>
38
- <?php if (1 != Mage::getStoreConfig('general/craftyclicks/active') ||
39
- 1 != Mage::getStoreConfig('general/craftyclicks/change_fields')) : ?>
40
  <li><div class="input-box">
41
  <label for="shipping:company"><?php echo $this->__('Company') ?></label><br/>
42
  <input type="text" id="shipping:company" name="shipping[company]" value="<?php echo $this->htmlEscape($this->getAddress()->getCompany()) ?>" title="<?php echo $this->__('Company') ?>" class="input-text" onchange="shipping.setSameAsBilling(false);" /></div>
@@ -47,15 +46,24 @@
47
  <?php endif ?>
48
  </li>
49
  <?php endif ?>
50
- <?php if (1 == Mage::getStoreConfig('general/craftyclicks/active') &&
51
- 1 == Mage::getStoreConfig('general/craftyclicks/change_fields')) : ?>
52
  <li><div class="input-box">
53
  <label for="shipping:country_id"><?php echo $this->__('Country') ?> <span class="required">*</span></label><br />
54
  <?php echo $this->getCountryHtmlSelect('shipping') ?></div>
55
- <div class="input-box">
56
  <label for="shipping:postcode"><?php echo $this->__('Zip/Postal Code') ?> <span class="required">*</span></label><br />
57
  <input type="text" title="<?php echo $this->__('Zip/Postal Code') ?>" name="shipping[postcode]" id="shipping:postcode" value="<?php echo $this->htmlEscape($this->getAddress()->getPostcode()) ?>" class="validate-zip-international required-entry input-text" onchange="shipping.setSameAsBilling(false);"/></div>
58
- </li>
 
 
 
 
 
 
 
 
 
 
59
  <li><div class="input-box">
60
  <label for="shipping:company"><?php echo $this->__('Company') ?></label><br/>
61
  <input type="text" id="shipping:company" name="shipping[company]" value="<?php echo $this->htmlEscape($this->getAddress()->getCompany()) ?>" title="<?php echo $this->__('Company') ?>" class="input-text" onchange="shipping.setSameAsBilling(false);" /></div>
@@ -78,8 +86,7 @@
78
  $('shipping:region_id').setAttribute('defaultValue', "<?php echo $this->getAddress()->getRegionId() ?>");
79
  </script>
80
  <input type="text" id="shipping:region" name="shipping[region]" value="<?php echo $this->htmlEscape($this->getAddress()->getRegion()) ?>" title="<?php echo $this->__('State/Province') ?>" class="input-text" style="display:none" /></div></li>
81
- <?php if (1 != Mage::getStoreConfig('general/craftyclicks/active') ||
82
- 1 != Mage::getStoreConfig('general/craftyclicks/change_fields')) : ?>
83
  <li><div class="input-box">
84
  <label for="shipping:postcode"><?php echo $this->__('Zip/Postal Code') ?> <span class="required">*</span></label><br />
85
  <input type="text" title="<?php echo $this->__('Zip/Postal Code') ?>" name="shipping[postcode]" id="shipping:postcode" value="<?php echo $this->htmlEscape($this->getAddress()->getPostcode()) ?>" class="validate-zip-international required-entry input-text" onchange="shipping.setSameAsBilling(false);"/></div>
35
  <ul>
36
  <li><?php echo $this->getLayout()->createBlock('customer/widget_name')->setObject($this->getAddress())
37
  ->setFieldIdFormat('shipping:%s')->setFieldNameFormat('shipping[%s]')->setFieldParams('onchange="shipping.setSameAsBilling(false)"')->toHtml() ?></li>
38
+ <?php if (1 != Mage::getStoreConfig('general/craftyclicks/active')) : ?>
 
39
  <li><div class="input-box">
40
  <label for="shipping:company"><?php echo $this->__('Company') ?></label><br/>
41
  <input type="text" id="shipping:company" name="shipping[company]" value="<?php echo $this->htmlEscape($this->getAddress()->getCompany()) ?>" title="<?php echo $this->__('Company') ?>" class="input-text" onchange="shipping.setSameAsBilling(false);" /></div>
46
  <?php endif ?>
47
  </li>
48
  <?php endif ?>
49
+ <?php if (1 == Mage::getStoreConfig('general/craftyclicks/active')) : ?>
 
50
  <li><div class="input-box">
51
  <label for="shipping:country_id"><?php echo $this->__('Country') ?> <span class="required">*</span></label><br />
52
  <?php echo $this->getCountryHtmlSelect('shipping') ?></div>
53
+ <div class="input-box" id="zipDiv2">
54
  <label for="shipping:postcode"><?php echo $this->__('Zip/Postal Code') ?> <span class="required">*</span></label><br />
55
  <input type="text" title="<?php echo $this->__('Zip/Postal Code') ?>" name="shipping[postcode]" id="shipping:postcode" value="<?php echo $this->htmlEscape($this->getAddress()->getPostcode()) ?>" class="validate-zip-international required-entry input-text" onchange="shipping.setSameAsBilling(false);"/></div>
56
+ <div class="input-box" id="findAddrBtnDiv2" style="display:none;"><br />
57
+ &nbsp;
58
+ <?php if ('' != Mage::getStoreConfig('general/craftyclicks/button_image')) : ?>
59
+ <img style="cursor: pointer;" src="<?php echo $this->getSkinUrl('craftyclicks/'.Mage::getStoreConfig('general/craftyclicks/button_image')); ?>" onclick="_cp_do_lookup2()" title="Find Address" class="<?php echo Mage::getStoreConfig('general/craftyclicks/button_class');?>"/>
60
+ <?php else : ?>
61
+ <button type="button" onclick="_cp_do_lookup2()" class="<?php echo Mage::getStoreConfig('general/craftyclicks/button_class');?>">Find Address</button>
62
+ <?php endif ?>
63
+ </div>
64
+ </li>
65
+ <li><span style="display:none;" id="crafty_postcode_result_display2">&nbsp;
66
+ </span></li>
67
  <li><div class="input-box">
68
  <label for="shipping:company"><?php echo $this->__('Company') ?></label><br/>
69
  <input type="text" id="shipping:company" name="shipping[company]" value="<?php echo $this->htmlEscape($this->getAddress()->getCompany()) ?>" title="<?php echo $this->__('Company') ?>" class="input-text" onchange="shipping.setSameAsBilling(false);" /></div>
86
  $('shipping:region_id').setAttribute('defaultValue', "<?php echo $this->getAddress()->getRegionId() ?>");
87
  </script>
88
  <input type="text" id="shipping:region" name="shipping[region]" value="<?php echo $this->htmlEscape($this->getAddress()->getRegion()) ?>" title="<?php echo $this->__('State/Province') ?>" class="input-text" style="display:none" /></div></li>
89
+ <?php if (1 != Mage::getStoreConfig('general/craftyclicks/active')) : ?>
 
90
  <li><div class="input-box">
91
  <label for="shipping:postcode"><?php echo $this->__('Zip/Postal Code') ?> <span class="required">*</span></label><br />
92
  <input type="text" title="<?php echo $this->__('Zip/Postal Code') ?>" name="shipping[postcode]" id="shipping:postcode" value="<?php echo $this->htmlEscape($this->getAddress()->getPostcode()) ?>" class="validate-zip-international required-entry input-text" onchange="shipping.setSameAsBilling(false);"/></div>
app/design/frontend/default/default/template/dnc/craftyclicks/crafty_template_helper.php CHANGED
@@ -13,28 +13,6 @@ function crafty_add_address_finder($obj, $suffix = '', $company_id = 'company',
13
 
14
  echo "<script type=\"text/javascript\">";
15
 
16
- if (1 == $conf['craftyclicks']['add_elements']) {
17
- // need to create the 'find address button and the results box
18
- $button_class = '';
19
- if (array_key_exists('button_class',$conf['craftyclicks']) && '' != $conf['craftyclicks']['button_class']) {
20
- $button_class = 'class="'.$conf['craftyclicks']['button_class'].'" ';
21
- }
22
- if (!array_key_exists('button_image',$conf['craftyclicks']) || '' == $conf['craftyclicks']['button_image']) {
23
- // default browser button
24
- $buttonHTML = "<span id=\"findAddrBtn".$suffix."\">&nbsp;&nbsp;<button type=\"button\" onclick=\"_cp_do_lookup".$suffix."()\" ".$button_class.">Find Address</button></span>";
25
- } else {
26
- $buttonHTML = "<span id=\"findAddrBtn".$suffix."\">&nbsp;&nbsp;<img style=\"cursor: pointer;\" src=\"".$obj->getSkinUrl('craftyclicks/'.$conf['craftyclicks']['button_image'])."\" onclick=\"_cp_do_lookup".$suffix."()\" title=\"Find Address\" ".$button_class."/></span>";
27
- }
28
-
29
- $resultHTML = "<div style=\"display:block; clear:both;\" id=\"crafty_postcode_result_display".$suffix."\">&nbsp;</div>";
30
- echo "
31
- var _cp_postcodeHTML = document.getElementById('".$postcode_id."').parentNode.innerHTML;
32
- document.getElementById('".$postcode_id."').parentNode.innerHTML = _cp_postcodeHTML+'".$buttonHTML."';
33
- var _cp_liHTML = document.getElementById('".$postcode_id."').parentNode.parentNode.innerHTML;
34
- document.getElementById('".$postcode_id."').parentNode.parentNode.innerHTML = _cp_liHTML+'".$resultHTML."';
35
- ";
36
- }
37
-
38
  if (1 == $conf['craftyclicks']['hide_fields'] && '' == $obj->getAddress()->getPostcode()) {
39
  // hide address fields if they are blank, only show them once an address is selected
40
  echo "
@@ -68,6 +46,7 @@ function crafty_add_address_finder($obj, $suffix = '', $company_id = 'company',
68
  echo "
69
  function _cp_addr_result_hide".$suffix."() {
70
  cp_obj".$suffix.".update_res(null);
 
71
  }
72
  ";
73
  } else {
@@ -98,6 +77,9 @@ function crafty_add_address_finder($obj, $suffix = '', $company_id = 'company',
98
  echo "
99
  function _cp_result_ready".$suffix."() {
100
  _cp_addr_fields_show".$suffix."();
 
 
 
101
  _cp_addr_result_hide".$suffix."();
102
  }
103
  function _cp_result_error".$suffix."() {
@@ -110,27 +92,34 @@ function crafty_add_address_finder($obj, $suffix = '', $company_id = 'company',
110
  function _cp_country_handler".$suffix."() {
111
  if ('GB' != document.getElementById('".$country_id."').value) {
112
  document.getElementById('".$postcode_id."').style.width = _cp_oldZipWidth".$suffix.";
113
- document.getElementById('findAddrBtn".$suffix."').style.display = 'none';
114
- _cp_result_ready".$suffix."();
 
 
115
  cp_obj".$suffix.".update_res(null);
116
  _cp_county_display".$suffix."('inline');
117
  } else {
118
- document.getElementById('".$postcode_id."').style.width = '80px';
119
- document.getElementById('findAddrBtn".$suffix."').style.display = 'inline';
 
 
120
  _cp_county_display".$suffix."('none');
121
  }
122
  }
123
  function _cp_do_lookup".$suffix."()
124
  {
125
  document.getElementById('crafty_postcode_result_display".$suffix."').className = '';
 
126
  cp_obj".$suffix.".doLookup();
127
  }
128
 
129
  var _cp_oldZipWidth".$suffix." = document.getElementById('". $postcode_id."').style.width;
 
130
  var _cp_countryElem".$suffix." = document.getElementById('".$country_id."');
131
- _cp_countryElem".$suffix.".onchange = _cp_country_handler".$suffix.";
132
- _cp_countryElem".$suffix.".onclick = _cp_country_handler".$suffix.";
133
- _cp_countryElem".$suffix.".onkeypress = _cp_country_handler".$suffix.";
 
134
 
135
  _cp_country_handler".$suffix."();
136
 
@@ -151,13 +140,16 @@ function crafty_add_address_finder($obj, $suffix = '', $company_id = 'company',
151
  $element_ids.=$town_id.','.$county_id.','.$postcode_id;
152
 
153
  echo "
154
- cp_obj".$suffix.".set('elements', '".$element_ids."');
155
- cp_obj".$suffix.".set('first_res_line', '----- please select your address ----');
156
  cp_obj".$suffix.".set('res_autoselect', '0');
157
  cp_obj".$suffix.".set('busy_img_url', '".$obj->getSkinUrl('craftyclicks/crafty_postcode_busy.gif')."');
158
- cp_obj".$suffix.".set('res_select_on_change', '0');
159
- cp_obj".$suffix.".set('on_result_selected', _cp_result_ready".$suffix.");
160
- cp_obj".$suffix.".set('on_error', _cp_result_error".$suffix.");";
 
 
 
 
161
  if (array_key_exists('error_msg_1',$conf['craftyclicks']) && '' != $conf['craftyclicks']['error_msg_1']) {
162
  echo " cp_obj".$suffix.".set('err_msg1', '".$conf['craftyclicks']['error_msg_1']."');";
163
  }
13
 
14
  echo "<script type=\"text/javascript\">";
15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  if (1 == $conf['craftyclicks']['hide_fields'] && '' == $obj->getAddress()->getPostcode()) {
17
  // hide address fields if they are blank, only show them once an address is selected
18
  echo "
46
  echo "
47
  function _cp_addr_result_hide".$suffix."() {
48
  cp_obj".$suffix.".update_res(null);
49
+ document.getElementById('crafty_postcode_result_display".$suffix."').style.display = 'none';
50
  }
51
  ";
52
  } else {
77
  echo "
78
  function _cp_result_ready".$suffix."() {
79
  _cp_addr_fields_show".$suffix."();
80
+ }
81
+
82
+ function _cp_result_selected".$suffix."() {
83
  _cp_addr_result_hide".$suffix."();
84
  }
85
  function _cp_result_error".$suffix."() {
92
  function _cp_country_handler".$suffix."() {
93
  if ('GB' != document.getElementById('".$country_id."').value) {
94
  document.getElementById('".$postcode_id."').style.width = _cp_oldZipWidth".$suffix.";
95
+ document.getElementById('zipDiv').style.width = _cp_oldZipDivWidth".$suffix.";
96
+ document.getElementById('findAddrBtnDiv".$suffix."').style.display = 'none';
97
+ document.getElementById('crafty_postcode_result_display".$suffix."').style.display = 'none';
98
+ _cp_addr_fields_show".$suffix."();
99
  cp_obj".$suffix.".update_res(null);
100
  _cp_county_display".$suffix."('inline');
101
  } else {
102
+ document.getElementById('".$postcode_id."').style.width = '135px';
103
+ document.getElementById('zipDiv".$suffix."').style.width = '150px';
104
+ document.getElementById('findAddrBtnDiv".$suffix."').style.width = '125px';
105
+ document.getElementById('findAddrBtnDiv".$suffix."').style.display = 'inline';
106
  _cp_county_display".$suffix."('none');
107
  }
108
  }
109
  function _cp_do_lookup".$suffix."()
110
  {
111
  document.getElementById('crafty_postcode_result_display".$suffix."').className = '';
112
+ document.getElementById('crafty_postcode_result_display".$suffix."').style.display = 'inline';
113
  cp_obj".$suffix.".doLookup();
114
  }
115
 
116
  var _cp_oldZipWidth".$suffix." = document.getElementById('". $postcode_id."').style.width;
117
+ var _cp_oldZipDivWidth".$suffix." = document.getElementById('zipDiv').style.width;
118
  var _cp_countryElem".$suffix." = document.getElementById('".$country_id."');
119
+
120
+ Event.observe(_cp_countryElem".$suffix.", 'change', _cp_country_handler".$suffix.");
121
+ Event.observe(_cp_countryElem".$suffix.", 'click', _cp_country_handler".$suffix.");
122
+ Event.observe(_cp_countryElem".$suffix.", 'keypress', _cp_country_handler".$suffix.");
123
 
124
  _cp_country_handler".$suffix."();
125
 
140
  $element_ids.=$town_id.','.$county_id.','.$postcode_id;
141
 
142
  echo "
143
+ cp_obj".$suffix.".set('elements', '".$element_ids."');
 
144
  cp_obj".$suffix.".set('res_autoselect', '0');
145
  cp_obj".$suffix.".set('busy_img_url', '".$obj->getSkinUrl('craftyclicks/crafty_postcode_busy.gif')."');
146
+ cp_obj".$suffix.".set('on_result_ready', _cp_result_ready".$suffix.");
147
+ cp_obj".$suffix.".set('on_result_selected', _cp_result_selected".$suffix.");
148
+ cp_obj".$suffix.".set('on_error', _cp_result_error".$suffix.");
149
+ ";
150
+ if (array_key_exists('first_res_line',$conf['craftyclicks']) && '' != $conf['craftyclicks']['first_res_line']) {
151
+ echo " cp_obj".$suffix.".set('first_res_line', '".$conf['craftyclicks']['first_res_line']."');";
152
+ }
153
  if (array_key_exists('error_msg_1',$conf['craftyclicks']) && '' != $conf['craftyclicks']['error_msg_1']) {
154
  echo " cp_obj".$suffix.".set('err_msg1', '".$conf['craftyclicks']['error_msg_1']."');";
155
  }
app/design/frontend/default/default/template/dnc/craftyclicks/customer/address/edit.phtml CHANGED
@@ -47,8 +47,7 @@
47
  <li>
48
  <?php echo $this->getLayout()->createBlock('customer/widget_name')->setObject($this->getAddress()->getFirstname() ? $this->getAddress() : $this->getCustomer())->toHtml() ?>
49
  </li>
50
- <?php if (1 != Mage::getStoreConfig('general/craftyclicks/active') ||
51
- 1 != Mage::getStoreConfig('general/craftyclicks/change_fields')) : ?>
52
  <li>
53
  <label for="company"><?php echo $this->__('Company') ?></label><br />
54
  <input type="text" name="company" id="company" title="<?php echo $this->__('Company') ?>" value="<?php echo $this->htmlEscape($this->getAddress()->getCompany()) ?>" class="input-text" />
@@ -69,18 +68,29 @@
69
  <fieldset class="group-select">
70
  <h4 class="legend"><?php echo $this->__('Address') ?></h4>
71
  <ul>
72
- <?php if (1 == Mage::getStoreConfig('general/craftyclicks/active') &&
73
- 1 == Mage::getStoreConfig('general/craftyclicks/change_fields')) : ?>
74
- <li>
75
  <div class="input-box">
76
  <label for="country"><?php echo $this->__('Country') ?> <span class="required">*</span></label><br />
77
  <?php echo $this->getCountryHtmlSelect() ?>
78
  </div>
79
- <div class="input-box">
80
  <label for="zip"><?php echo $this->__('Zip/Postal Code') ?> <span class="required">*</span></label><br />
81
  <input type="text" name="postcode" value="<?php echo $this->htmlEscape($this->getAddress()->getPostcode()) ?>" title="<?php echo $this->__('Zip/Postal Code') ?>" id="zip" class="validate-zip-international required-entry input-text" />
82
- </div>
83
- </li>
 
 
 
 
 
 
 
 
 
 
 
 
84
  <li>
85
  <label for="company"><?php echo $this->__('Company') ?></label><br />
86
  <input type="text" name="company" id="company" title="<?php echo $this->__('Company') ?>" value="<?php echo $this->htmlEscape($this->getAddress()->getCompany()) ?>" class="input-text" />
@@ -111,8 +121,7 @@
111
  <input type="text" id="region" name="region" value="<?php echo $this->htmlEscape($this->getAddress()->getRegion()) ?>" title="<?php echo $this->__('State/Province') ?>" class="input-text" style="display:none" />
112
  </div>
113
  </li>
114
- <?php if (1 != Mage::getStoreConfig('general/craftyclicks/active') ||
115
- 1 != Mage::getStoreConfig('general/craftyclicks/change_fields')) : ?>
116
  <li>
117
  <div class="input-box">
118
  <label for="zip"><?php echo $this->__('Zip/Postal Code') ?> <span class="required">*</span></label><br />
47
  <li>
48
  <?php echo $this->getLayout()->createBlock('customer/widget_name')->setObject($this->getAddress()->getFirstname() ? $this->getAddress() : $this->getCustomer())->toHtml() ?>
49
  </li>
50
+ <?php if (1 != Mage::getStoreConfig('general/craftyclicks/active')) : ?>
 
51
  <li>
52
  <label for="company"><?php echo $this->__('Company') ?></label><br />
53
  <input type="text" name="company" id="company" title="<?php echo $this->__('Company') ?>" value="<?php echo $this->htmlEscape($this->getAddress()->getCompany()) ?>" class="input-text" />
68
  <fieldset class="group-select">
69
  <h4 class="legend"><?php echo $this->__('Address') ?></h4>
70
  <ul>
71
+ <?php if (1 == Mage::getStoreConfig('general/craftyclicks/active')) : ?>
72
+ <li>
 
73
  <div class="input-box">
74
  <label for="country"><?php echo $this->__('Country') ?> <span class="required">*</span></label><br />
75
  <?php echo $this->getCountryHtmlSelect() ?>
76
  </div>
77
+ <div class="input-box" id="zipDiv">
78
  <label for="zip"><?php echo $this->__('Zip/Postal Code') ?> <span class="required">*</span></label><br />
79
  <input type="text" name="postcode" value="<?php echo $this->htmlEscape($this->getAddress()->getPostcode()) ?>" title="<?php echo $this->__('Zip/Postal Code') ?>" id="zip" class="validate-zip-international required-entry input-text" />
80
+ </div>
81
+ <div class="input-box" id="findAddrBtnDiv" style="display:none;">
82
+ <br />
83
+ &nbsp;
84
+ <?php if ('' != Mage::getStoreConfig('general/craftyclicks/button_image')) : ?>
85
+ <img style="cursor: pointer;" src="<?php echo $this->getSkinUrl('craftyclicks/'.Mage::getStoreConfig('general/craftyclicks/button_image')); ?>" onclick="_cp_do_lookup()" title="Find Address" class="<?php echo Mage::getStoreConfig('general/craftyclicks/button_class');?>"/>
86
+ <?php else : ?>
87
+ <button type="button" onclick="_cp_do_lookup()" class="<?php echo Mage::getStoreConfig('general/craftyclicks/button_class');?>">Find Address</button>
88
+ <?php endif ?>
89
+ </div>
90
+ </li>
91
+ <li><span style="display:none;" id="crafty_postcode_result_display">
92
+ &nbsp;
93
+ </span></li>
94
  <li>
95
  <label for="company"><?php echo $this->__('Company') ?></label><br />
96
  <input type="text" name="company" id="company" title="<?php echo $this->__('Company') ?>" value="<?php echo $this->htmlEscape($this->getAddress()->getCompany()) ?>" class="input-text" />
121
  <input type="text" id="region" name="region" value="<?php echo $this->htmlEscape($this->getAddress()->getRegion()) ?>" title="<?php echo $this->__('State/Province') ?>" class="input-text" style="display:none" />
122
  </div>
123
  </li>
124
+ <?php if (1 != Mage::getStoreConfig('general/craftyclicks/active')) : ?>
 
125
  <li>
126
  <div class="input-box">
127
  <label for="zip"><?php echo $this->__('Zip/Postal Code') ?> <span class="required">*</span></label><br />
app/etc/modules/Dnc_Craftyclicks.xml CHANGED
@@ -4,7 +4,7 @@
4
  <Dnc_Craftyclicks>
5
  <active>true</active>
6
  <codePool>local</codePool>
7
- <version>1.4.0</version>
8
  </Dnc_Craftyclicks>
9
  </modules>
10
  </config>
4
  <Dnc_Craftyclicks>
5
  <active>true</active>
6
  <codePool>local</codePool>
7
+ <version>1.5.0</version>
8
  </Dnc_Craftyclicks>
9
  </modules>
10
  </config>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>UK_Postcode_Address_Finder</name>
4
- <version>1.4.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/osl-3.0.php">Open Software License ("OSL") v. 3.0</license>
7
  <channel>community</channel>
@@ -17,6 +17,13 @@ Please note:
17
 
18
  2. The extension is free to try and install, but to go live a paid up account with CraftyClicks.co.uk will be required. For current prices please go to http://www.craftyclicks.co.uk/prices</description>
19
  <notes>Release History :
 
 
 
 
 
 
 
20
  v 1.4.0
21
  * make error message class configurable - it can now be styled to match other Magento errors
22
  * make error message text configurable
@@ -47,9 +54,9 @@ v 1.1.0
47
 
48
  v 1.0.0 - Initial Release</notes>
49
  <authors><author><name>Adam Stylo</name><user>auto-converted</user><email>adam@craftyclicks.co.uk</email></author></authors>
50
- <date>2009-10-06</date>
51
- <time>14:08:54</time>
52
- <contents><target name="mage"><dir name="app"><dir name="design"><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="craftyclicks.xml" hash="3167430f327a75925cb13d037b517e8f"/></dir><dir name="template"><dir name="dnc"><dir name="craftyclicks"><file name="address_form.phtml" hash="fcb3cc2696ac5b98c9ba7a2e87d908ae"/><file name="checkout_onepage.phtml" hash="a083c7d757e759520543e1d13e86191c"/><file name="crafty_template_helper.php" hash="b3e03aa8f291664695ca7b02461f5e6f"/><dir name="checkout"><dir name="onepage"><file name="billing.phtml" hash="d80f77c43a935a9b1c46206822e4a6b8"/><file name="shipping.phtml" hash="3524544b27ae6046161e8c39ffe5fa36"/></dir></dir><dir name="customer"><dir name="address"><file name="edit.phtml" hash="b851dd752bd9f514ba5912525d9c21eb"/></dir></dir></dir></dir></dir></dir></dir></dir></dir><dir name="etc"><dir name="modules"><file name="Dnc_Craftyclicks.xml" hash="127ba6f97809015e3d88afc2ee367999"/></dir></dir></dir></target><target name="magelocal"><dir name="Dnc"><dir name="Craftyclicks"><dir name="etc"><file name="config.xml" hash="d62fa29e6168aa9d042105f764ffb879"/><file name="system.xml" hash="4a5aa7ffb9ca119c25c5f8fefa9d2e9f"/></dir><dir name="Helper"><file name="Data.php" hash="10c8592d3f990953767d6c96c2d0d5f4"/></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="default"><dir name="default"><dir name="craftyclicks"><file name="button_find_address.gif" hash="eb17331be28df3bd05fc1236202f262a"/><file name="crafty_postcode_busy.gif" hash="618a14f4dca4f51100cd2400e7f9049c"/></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="crafty"><file name="crafty_postcode.js" hash="4cf8526ef38554c5ff14b25fc66aea3c"/></dir></dir></target></contents>
53
  <compatible/>
54
  <dependencies/>
55
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>UK_Postcode_Address_Finder</name>
4
+ <version>1.5.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/osl-3.0.php">Open Software License ("OSL") v. 3.0</license>
7
  <channel>community</channel>
17
 
18
  2. The extension is free to try and install, but to go live a paid up account with CraftyClicks.co.uk will be required. For current prices please go to http://www.craftyclicks.co.uk/prices</description>
19
  <notes>Release History :
20
+ v 1.5.0
21
+ * add config option for 1st result line.
22
+ * avoid using JavaScript DOM for modifying address forms - it was conflicting with Magento JavaScript.
23
+ We now edit the template .phtml files directly.
24
+ * fix problems with re-displaying state select box when country is changed from UK to USA.
25
+ * fix problem with postcode error message affecting button position if form was submitted with a blank postcode.
26
+
27
  v 1.4.0
28
  * make error message class configurable - it can now be styled to match other Magento errors
29
  * make error message text configurable
54
 
55
  v 1.0.0 - Initial Release</notes>
56
  <authors><author><name>Adam Stylo</name><user>auto-converted</user><email>adam@craftyclicks.co.uk</email></author></authors>
57
+ <date>2009-12-04</date>
58
+ <time>10:37:31</time>
59
+ <contents><target name="mage"><dir name="app"><dir name="design"><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="craftyclicks.xml" hash="3167430f327a75925cb13d037b517e8f"/></dir><dir name="template"><dir name="dnc"><dir name="craftyclicks"><file name="address_form.phtml" hash="fcb3cc2696ac5b98c9ba7a2e87d908ae"/><file name="checkout_onepage.phtml" hash="a083c7d757e759520543e1d13e86191c"/><file name="crafty_template_helper.php" hash="acb82df4fcb2ba40271c9633f17cb7a0"/><dir name="checkout"><dir name="onepage"><file name="billing.phtml" hash="f51ac769fb1e90cd4ea6e8bba3ac819d"/><file name="shipping.phtml" hash="69a42e999e1ccd5ebebd4b12ad9720d7"/></dir></dir><dir name="customer"><dir name="address"><file name="edit.phtml" hash="3742dd587b877780b7229e81704a9232"/></dir></dir></dir></dir></dir></dir></dir></dir></dir><dir name="etc"><dir name="modules"><file name="Dnc_Craftyclicks.xml" hash="4de8ea2a29de0295e8766d4ba3a2071d"/></dir></dir></dir></target><target name="magelocal"><dir name="Dnc"><dir name="Craftyclicks"><dir name="etc"><file name="config.xml" hash="d4bdd4a6f9bce07bbb0968343e46d23a"/><file name="system.xml" hash="52c6a51d533deb0e296344ff93ed23eb"/></dir><dir name="Helper"><file name="Data.php" hash="10c8592d3f990953767d6c96c2d0d5f4"/></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="default"><dir name="default"><dir name="craftyclicks"><file name="button_find_address.gif" hash="0fdef9bf7ad0f7ec3f6530b7ff40bf59"/><file name="crafty_postcode_busy.gif" hash="618a14f4dca4f51100cd2400e7f9049c"/></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="crafty"><file name="crafty_postcode.js" hash="4cf8526ef38554c5ff14b25fc66aea3c"/></dir></dir></target></contents>
60
  <compatible/>
61
  <dependencies/>
62
  </package>
skin/frontend/default/default/craftyclicks/button_find_address.gif CHANGED
Binary file