Version Notes
Changes:
- Improved 'Never hide country selector' option to also work for regular checkouts
- Added provisional support for GrafischDirect One Step Checkout
- Improved address housenumber addition user input matching
- More Magento coding-standards compliant
Download this release
Release Info
Developer | Magento Core Team |
Extension | PostcodeNl_Api |
Version | 1.0.7.0 |
Comparing to | |
See all releases |
Code changes from version 1.0.6.5 to 1.0.7.0
- app/code/community/PostcodeNl/Api/Helper/Data.php +1 -1
- app/code/community/PostcodeNl/Api/controllers/Adminhtml/PcnlController.php +6 -2
- app/code/community/PostcodeNl/Api/controllers/JsonController.php +8 -3
- app/code/community/PostcodeNl/Api/etc/config.xml +1 -1
- app/code/community/PostcodeNl/Api/etc/system.xml +2 -2
- js/postcodenl/api/lookup.js +86 -92
- package.xml +8 -5
- skin/frontend/base/default/postcodenl/api/css/lookup.css +2 -2
app/code/community/PostcodeNl/Api/Helper/Data.php
CHANGED
@@ -71,7 +71,7 @@ class PostcodeNl_Api_Helper_Data extends Mage_Core_Helper_Abstract
|
|
71 |
curl_setopt($ch, CURLOPT_URL, $url);
|
72 |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
73 |
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, self::API_TIMEOUT);
|
74 |
-
curl_setopt($ch, CURLOPT_HTTPAUTH,
|
75 |
curl_setopt($ch, CURLOPT_USERPWD, $serviceKey .':'. $serviceSecret);
|
76 |
curl_setopt($ch, CURLOPT_USERAGENT, 'PostcodeNl_Api_MagentoPlugin/' . $extensionVersion .' '. $this->_getMagentoVersion());
|
77 |
$jsonResponse = curl_exec($ch);
|
71 |
curl_setopt($ch, CURLOPT_URL, $url);
|
72 |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
73 |
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, self::API_TIMEOUT);
|
74 |
+
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
|
75 |
curl_setopt($ch, CURLOPT_USERPWD, $serviceKey .':'. $serviceSecret);
|
76 |
curl_setopt($ch, CURLOPT_USERAGENT, 'PostcodeNl_Api_MagentoPlugin/' . $extensionVersion .' '. $this->_getMagentoVersion());
|
77 |
$jsonResponse = curl_exec($ch);
|
app/code/community/PostcodeNl/Api/controllers/Adminhtml/PcnlController.php
CHANGED
@@ -3,9 +3,13 @@ class PostcodeNl_Api_Adminhtml_PcnlController extends Mage_Adminhtml_Controller_
|
|
3 |
{
|
4 |
public function lookupAction()
|
5 |
{
|
6 |
-
$helper =
|
7 |
|
8 |
$this->getResponse()->setHeader('Content-type', 'application/json');
|
9 |
-
$this->getResponse()->setBody(json_encode($helper->lookupAddress(
|
|
|
|
|
|
|
|
|
10 |
}
|
11 |
}
|
3 |
{
|
4 |
public function lookupAction()
|
5 |
{
|
6 |
+
$helper = Mage::helper('postcodenl_api');
|
7 |
|
8 |
$this->getResponse()->setHeader('Content-type', 'application/json');
|
9 |
+
$this->getResponse()->setBody(json_encode($helper->lookupAddress(
|
10 |
+
$this->getRequest()->getParam('postcode'),
|
11 |
+
$this->getRequest()->getParam('houseNumber'),
|
12 |
+
$this->getRequest()->getParam('houseNumberAddition')
|
13 |
+
)));
|
14 |
}
|
15 |
}
|
app/code/community/PostcodeNl/Api/controllers/JsonController.php
CHANGED
@@ -3,8 +3,13 @@ class PostcodeNl_Api_JsonController extends Mage_Core_Controller_Front_Action
|
|
3 |
{
|
4 |
public function lookupAction()
|
5 |
{
|
6 |
-
$helper =
|
7 |
-
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
9 |
}
|
10 |
}
|
3 |
{
|
4 |
public function lookupAction()
|
5 |
{
|
6 |
+
$helper = Mage::helper('postcodenl_api');
|
7 |
+
|
8 |
+
$this->getResponse()->setHeader('Content-type', 'application/json');
|
9 |
+
$this->getResponse()->setBody(json_encode($helper->lookupAddress(
|
10 |
+
$this->getRequest()->getParam('postcode'),
|
11 |
+
$this->getRequest()->getParam('houseNumber'),
|
12 |
+
$this->getRequest()->getParam('houseNumberAddition')
|
13 |
+
)));
|
14 |
}
|
15 |
}
|
app/code/community/PostcodeNl/Api/etc/config.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<PostcodeNl_Api>
|
5 |
-
<version>1.0.
|
6 |
</PostcodeNl_Api>
|
7 |
</modules>
|
8 |
<frontend>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<PostcodeNl_Api>
|
5 |
+
<version>1.0.7.0</version>
|
6 |
</PostcodeNl_Api>
|
7 |
</modules>
|
8 |
<frontend>
|
app/code/community/PostcodeNl/Api/etc/system.xml
CHANGED
@@ -80,8 +80,8 @@
|
|
80 |
<show_in_store>1</show_in_store>
|
81 |
<comment>
|
82 |
<![CDATA[
|
83 |
-
For webshops with a more international audience, do not hide the country
|
84 |
-
<b>Note</b>:
|
85 |
]]></comment>
|
86 |
</never_hide_country>
|
87 |
<api_showcase translate="label">
|
80 |
<show_in_store>1</show_in_store>
|
81 |
<comment>
|
82 |
<![CDATA[
|
83 |
+
For webshops with a more international audience, do not hide the country selection box.
|
84 |
+
<b>Note</b>: If there are other fields next to the country selector, they will be disabled.
|
85 |
]]></comment>
|
86 |
</never_hide_country>
|
87 |
<api_showcase translate="label">
|
js/postcodenl/api/lookup.js
CHANGED
@@ -37,35 +37,24 @@ document.observe("dom:loaded", function()
|
|
37 |
*/
|
38 |
REGEXP_STREET: '[^0-9].*?|.*?[^0-9]',
|
39 |
REGEXP_HOUSENUMBER: '[0-9]+',
|
40 |
-
REGEXP_HOUSENUMBER_ADDITION: '[
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
/**
|
43 |
* Hide multiple field-rows in forms
|
44 |
*/
|
45 |
hideFields: function (fields)
|
46 |
{
|
|
|
47 |
fields.each(function (fieldId)
|
48 |
{
|
49 |
-
if ($(fieldId))
|
50 |
{
|
51 |
-
|
52 |
-
{
|
53 |
-
// For `IWD Free One Page / Step Checkout`
|
54 |
-
$(fieldId).up('div.two_fields').addClassName('pcnl-hidden-field');
|
55 |
-
}
|
56 |
-
else if ($(fieldId).up('div.full'))
|
57 |
-
{
|
58 |
-
// For `IWD Free One Page / Step Checkout`
|
59 |
-
$(fieldId).up('div.full').addClassName('pcnl-hidden-field');
|
60 |
-
}
|
61 |
-
else if ($(fieldId).up('li'))
|
62 |
-
{
|
63 |
-
$(fieldId).up('li').addClassName('pcnl-hidden-field');
|
64 |
-
}
|
65 |
-
else if ($(fieldId).up('tr'))
|
66 |
-
{
|
67 |
-
$(fieldId).up('tr').addClassName('pcnl-hidden-field');
|
68 |
-
}
|
69 |
}
|
70 |
});
|
71 |
},
|
@@ -75,28 +64,12 @@ document.observe("dom:loaded", function()
|
|
75 |
*/
|
76 |
showFields: function (fields)
|
77 |
{
|
|
|
78 |
fields.each(function (fieldId)
|
79 |
{
|
80 |
-
if ($(fieldId))
|
81 |
{
|
82 |
-
|
83 |
-
{
|
84 |
-
// For `IWD Free One Page / Step Checkout`
|
85 |
-
$(fieldId).up('div.two_fields').removeClassName('pcnl-hidden-field');
|
86 |
-
}
|
87 |
-
else if ($(fieldId).up('div.full'))
|
88 |
-
{
|
89 |
-
// For `IWD Free One Page / Step Checkout`
|
90 |
-
$(fieldId).up('div.full').removeClassName('pcnl-hidden-field');
|
91 |
-
}
|
92 |
-
else if ($(fieldId).up('li'))
|
93 |
-
{
|
94 |
-
$(fieldId).up('li').removeClassName('pcnl-hidden-field');
|
95 |
-
}
|
96 |
-
else if ($(fieldId).up('tr'))
|
97 |
-
{
|
98 |
-
$(fieldId).up('tr').removeClassName('pcnl-hidden-field');
|
99 |
-
}
|
100 |
}
|
101 |
});
|
102 |
},
|
@@ -138,9 +111,9 @@ document.observe("dom:loaded", function()
|
|
138 |
{
|
139 |
Element.remove($(prefix +'postcode_housenumber_addition:wrapper'));
|
140 |
}
|
141 |
-
if ($(prefix + 'postcode_housenumber').up(
|
142 |
{
|
143 |
-
$(prefix + 'postcode_housenumber').up(
|
144 |
}
|
145 |
}
|
146 |
},
|
@@ -169,7 +142,7 @@ document.observe("dom:loaded", function()
|
|
169 |
if (prop == 'modules') {
|
170 |
html += '<dt>'+ name.escapeHTML() +'</dt><dd>';
|
171 |
for (var moduleName in data[prop]) {
|
172 |
-
html += String(moduleName +'-'+ data[prop][moduleName].codePool + (data[prop][moduleName].version
|
173 |
}
|
174 |
html += '</dd>';
|
175 |
}
|
@@ -250,7 +223,7 @@ document.observe("dom:loaded", function()
|
|
250 |
var housenumber_mixed = $(prefix + 'postcode_housenumber').getValue().trim();
|
251 |
// Number, followed by non alphanumberic chars, and then additional number ("123 A", "123-rood", etc)
|
252 |
// or: Number, followed directly by a letter and then alphanumeric/space charcters ("123b3", "123berk 23", etc)
|
253 |
-
var housenumber_match = housenumber_mixed.match('^('+ this.REGEXP_HOUSENUMBER +')([^0-9a-zA-Z]*('+ this.REGEXP_HOUSENUMBER_ADDITION +'))
|
254 |
|
255 |
var housenumber_addition_select = $(prefix +'postcode_housenumber_addition') ? $(prefix +'postcode_housenumber_addition').getValue() : null;
|
256 |
|
@@ -260,7 +233,7 @@ document.observe("dom:loaded", function()
|
|
260 |
|
261 |
if (!housenumber_match)
|
262 |
housenumber_addition = '';
|
263 |
-
else if (housenumber_match[3])
|
264 |
housenumber_addition = housenumber_match[3].trim();
|
265 |
|
266 |
if (housenumber_addition == '' && housenumber_addition_select != '__none__' && housenumber_addition_select != '__select__' && housenumber_addition_select != null)
|
@@ -273,7 +246,7 @@ document.observe("dom:loaded", function()
|
|
273 |
postcode = postcode.toUpperCase();
|
274 |
|
275 |
var url = PCNLAPI_CONFIG.baseUrl +'lookup?postcode=' + postcode + '&houseNumber=' + housenumber + '&houseNumberAddition=' + housenumber_addition;
|
276 |
-
if (
|
277 |
{
|
278 |
new Ajax.Request(url,
|
279 |
{
|
@@ -316,19 +289,22 @@ document.observe("dom:loaded", function()
|
|
316 |
map = '<iframe frameborder="0" scrolling="no" marginheight="0" marginwidth="0" class="map" src="http://maps.google.com/maps?t=h&q='+ data.showcaseResponse.latitude +','+ data.showcaseResponse.longitude +'+(Location found)&z=19&output=embed&iwloc=near"></iframe>';
|
317 |
}
|
318 |
|
319 |
-
if ($(prefix +
|
320 |
-
{
|
321 |
-
// We're probably in the admin
|
322 |
-
$(prefix + street1).up('tr').insert({before: '<tr id="' + prefix + 'showcase"><td class="label">'+ PCNLAPI_CONFIG.translations.apiShowcase.escapeHTML() +'</label></td><td class="value"><h4 class="pcnl-showcase">'+ PCNLAPI_CONFIG.translations.apiShowcase.escapeHTML() +'</h4>'+ info + '</td></tr>'});
|
323 |
-
}
|
324 |
-
else if ($(prefix + street1).up('div.full'))
|
325 |
{
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
332 |
}
|
333 |
}
|
334 |
if (PCNLAPI_CONFIG.debug)
|
@@ -338,26 +314,29 @@ document.observe("dom:loaded", function()
|
|
338 |
|
339 |
var info = this.getFieldListHtml(data.debugInfo, 'pcnl-debug');
|
340 |
|
341 |
-
if ($(prefix +
|
342 |
-
{
|
343 |
-
// We're probably in the admin
|
344 |
-
$(prefix + street1).up('tr').insert({before: '<tr id="' + prefix + 'debug"><td class="label">'+ PCNLAPI_CONFIG.translations.apiDebug.escapeHTML() +'</label></td><td class="value"><h4 class="pcnl-debug">'+ PCNLAPI_CONFIG.translations.apiDebug.escapeHTML() +'</h4>'+ info + '</td></tr>'});
|
345 |
-
}
|
346 |
-
else if ($(prefix + street1).up('div.full'))
|
347 |
{
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
354 |
}
|
355 |
}
|
356 |
|
357 |
// Remove any existing error messages
|
358 |
this.removeValidationMessages(prefix);
|
359 |
|
360 |
-
if (data.postcode
|
361 |
{
|
362 |
// Set data from request on form fields
|
363 |
var postcodeChange = false;
|
@@ -429,7 +408,7 @@ document.observe("dom:loaded", function()
|
|
429 |
this.removeHousenumberAddition(prefix);
|
430 |
}
|
431 |
}
|
432 |
-
else if (data.message
|
433 |
{
|
434 |
// Address check returned an error
|
435 |
|
@@ -452,6 +431,7 @@ document.observe("dom:loaded", function()
|
|
452 |
|
453 |
// Add support for syncing Billing & Shipping
|
454 |
if (prefix == 'billing:' && $('shipping:' + postcodeFieldId)) {
|
|
|
455 |
if (typeof shipping != 'undefined') {
|
456 |
if ($('shipping:same_as_billing') && $('shipping:same_as_billing').checked) {
|
457 |
shipping.syncWithBilling();
|
@@ -473,9 +453,12 @@ document.observe("dom:loaded", function()
|
|
473 |
|
474 |
if (!$(prefix +'postcode_input:wrapper'))
|
475 |
{
|
476 |
-
if ($(prefix + postcodeFieldId).parentNode.tagName == 'TD')
|
477 |
{
|
478 |
-
// We're probably in the admin
|
|
|
|
|
|
|
479 |
if (PCNLAPI_CONFIG.adminValidationDisabled)
|
480 |
{
|
481 |
return;
|
@@ -553,6 +536,24 @@ document.observe("dom:loaded", function()
|
|
553 |
}
|
554 |
$(prefix + 'country_id').up('li').insert({before: '<li id="' + prefix + 'postcode_input:output" class="pcnl-hidden-field"><div class="input-box"><label>'+ PCNLAPI_CONFIG.translations.outputLabel +'</label><div id="' + prefix + 'postcode_output" class="pcnl-address-text"></div></div></li>'});
|
555 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
556 |
else if ($(document.body).hasClassName('checkout-onestep-index'))
|
557 |
{
|
558 |
// FME One Step Checkout
|
@@ -573,6 +574,8 @@ document.observe("dom:loaded", function()
|
|
573 |
{
|
574 |
// IWD Free One Page / Step Checkout
|
575 |
|
|
|
|
|
576 |
if (!$(prefix +'postcode_input:info'))
|
577 |
{
|
578 |
$(prefix + street1).up('div.full').insert({before: '<div id="' + prefix + 'postcode_input:info" class="full"><div><label class="pcnl-info-label">'+ PCNLAPI_CONFIG.translations.infoLabel +'</label><div class="pcnl-info-text">'+ PCNLAPI_CONFIG.translations.infoText +'</div></div></div>'});
|
@@ -644,20 +647,20 @@ document.observe("dom:loaded", function()
|
|
644 |
var housenumber_addition = '';
|
645 |
if (PCNLAPI_CONFIG.useStreet2AsHouseNumber && $(prefix + street2))
|
646 |
{
|
647 |
-
housenumber_match = $(prefix + street2).getValue().match('^('+ this.REGEXP_HOUSENUMBER +')([^0-9a-zA-Z]*('+ this.REGEXP_HOUSENUMBER_ADDITION +'))
|
648 |
if (housenumber_match)
|
649 |
{
|
650 |
housenumber = housenumber_match[1].trim();
|
651 |
-
housenumber_addition = housenumber_match[3].trim();
|
652 |
}
|
653 |
}
|
654 |
else
|
655 |
{
|
656 |
-
housenumber_match = $(prefix + street1).getValue().match('^('+ this.REGEXP_STREET +')
|
657 |
if (housenumber_match)
|
658 |
{
|
659 |
housenumber = housenumber_match[2].trim();
|
660 |
-
housenumber_addition = housenumber_match[4].trim();
|
661 |
}
|
662 |
}
|
663 |
|
@@ -721,11 +724,11 @@ document.observe("dom:loaded", function()
|
|
721 |
prefix + street4,
|
722 |
prefix + 'city',
|
723 |
prefix + 'region',
|
724 |
-
|
725 |
]);
|
726 |
-
if (
|
727 |
{
|
728 |
-
this.
|
729 |
}
|
730 |
|
731 |
// Set empty, will be corrected later
|
@@ -800,25 +803,16 @@ document.observe("dom:loaded", function()
|
|
800 |
options += '<option value="'+ (value == '' ? '__none__' : value.escapeHTML()) +'">'+ (value == '' ? PCNLAPI_CONFIG.translations.noAdditionSelect : value ).escapeHTML() +'</option>';
|
801 |
});
|
802 |
|
803 |
-
if (
|
804 |
{
|
805 |
// We're probably in the admin
|
806 |
-
$(prefix + 'postcode_housenumber').up(
|
807 |
}
|
808 |
else
|
809 |
{
|
810 |
// We're probably in the frontend
|
811 |
$(prefix + 'postcode_housenumber').insert({after: '<select title="'+ PCNLAPI_CONFIG.translations.houseNumberAdditionTitle +'" name="'+ prefix + 'postcode_housenumber_addition" id="' + prefix + 'postcode_housenumber_addition" class="validate-select pcnl-input-text-half">'+ options +'</select>'});
|
812 |
-
|
813 |
-
{
|
814 |
-
// IWD checkout module
|
815 |
-
$(prefix + 'postcode_housenumber').up('div.short').addClassName('pcnl-with-addition');
|
816 |
-
}
|
817 |
-
else
|
818 |
-
{
|
819 |
-
// Other checkout modules
|
820 |
-
$(prefix + 'postcode_housenumber').up('li').addClassName('pcnl-with-addition');
|
821 |
-
}
|
822 |
}
|
823 |
|
824 |
$(prefix +'postcode_housenumber_addition').observe('change', function(e) { pcnlapi.lookupPostcode(prefix, postcodeFieldId, countryFieldId, street1, street2, street3, street4, e); });
|
37 |
*/
|
38 |
REGEXP_STREET: '[^0-9].*?|.*?[^0-9]',
|
39 |
REGEXP_HOUSENUMBER: '[0-9]+',
|
40 |
+
REGEXP_HOUSENUMBER_ADDITION: '[^\\s]+|[^\\s]\\s+[^\\s]{1,4}',
|
41 |
+
|
42 |
+
/*
|
43 |
+
* The 'item' parent element signature in the address form
|
44 |
+
*/
|
45 |
+
parentElementType: 'li',
|
46 |
|
47 |
/**
|
48 |
* Hide multiple field-rows in forms
|
49 |
*/
|
50 |
hideFields: function (fields)
|
51 |
{
|
52 |
+
var pcnl = this;
|
53 |
fields.each(function (fieldId)
|
54 |
{
|
55 |
+
if ($(fieldId) && $(fieldId).up(pcnl.parentElementType))
|
56 |
{
|
57 |
+
$(fieldId).up(pcnl.parentElementType).addClassName('pcnl-hidden-field')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
}
|
59 |
});
|
60 |
},
|
64 |
*/
|
65 |
showFields: function (fields)
|
66 |
{
|
67 |
+
var pcnl = this;
|
68 |
fields.each(function (fieldId)
|
69 |
{
|
70 |
+
if ($(fieldId) && $(fieldId).up(pcnl.parentElementType))
|
71 |
{
|
72 |
+
$(fieldId).up(pcnl.parentElementType).removeClassName('pcnl-hidden-field')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
}
|
74 |
});
|
75 |
},
|
111 |
{
|
112 |
Element.remove($(prefix +'postcode_housenumber_addition:wrapper'));
|
113 |
}
|
114 |
+
if ($(prefix + 'postcode_housenumber').up(this.parentElementType))
|
115 |
{
|
116 |
+
$(prefix + 'postcode_housenumber').up(this.parentElementType).removeClassName('pcnl-with-addition');
|
117 |
}
|
118 |
}
|
119 |
},
|
142 |
if (prop == 'modules') {
|
143 |
html += '<dt>'+ name.escapeHTML() +'</dt><dd>';
|
144 |
for (var moduleName in data[prop]) {
|
145 |
+
html += String(moduleName +'-'+ data[prop][moduleName].codePool + (data[prop][moduleName].version !== undefined ? '-' + data[prop][moduleName].version : '') + (data[prop][moduleName].active ? '' : ' (inactive)')).escapeHTML() +'<br />';
|
146 |
}
|
147 |
html += '</dd>';
|
148 |
}
|
223 |
var housenumber_mixed = $(prefix + 'postcode_housenumber').getValue().trim();
|
224 |
// Number, followed by non alphanumberic chars, and then additional number ("123 A", "123-rood", etc)
|
225 |
// or: Number, followed directly by a letter and then alphanumeric/space charcters ("123b3", "123berk 23", etc)
|
226 |
+
var housenumber_match = housenumber_mixed.match('^('+ this.REGEXP_HOUSENUMBER +')([^0-9a-zA-Z]*('+ this.REGEXP_HOUSENUMBER_ADDITION +'))?\\s*$');
|
227 |
|
228 |
var housenumber_addition_select = $(prefix +'postcode_housenumber_addition') ? $(prefix +'postcode_housenumber_addition').getValue() : null;
|
229 |
|
233 |
|
234 |
if (!housenumber_match)
|
235 |
housenumber_addition = '';
|
236 |
+
else if (housenumber_match[3] !== undefined)
|
237 |
housenumber_addition = housenumber_match[3].trim();
|
238 |
|
239 |
if (housenumber_addition == '' && housenumber_addition_select != '__none__' && housenumber_addition_select != '__select__' && housenumber_addition_select != null)
|
246 |
postcode = postcode.toUpperCase();
|
247 |
|
248 |
var url = PCNLAPI_CONFIG.baseUrl +'lookup?postcode=' + postcode + '&houseNumber=' + housenumber + '&houseNumberAddition=' + housenumber_addition;
|
249 |
+
if (this.requestCache[url] === undefined)
|
250 |
{
|
251 |
new Ajax.Request(url,
|
252 |
{
|
289 |
map = '<iframe frameborder="0" scrolling="no" marginheight="0" marginwidth="0" class="map" src="http://maps.google.com/maps?t=h&q='+ data.showcaseResponse.latitude +','+ data.showcaseResponse.longitude +'+(Location found)&z=19&output=embed&iwloc=near"></iframe>';
|
290 |
}
|
291 |
|
292 |
+
if ($(prefix + street1).up(this.parentElementType))
|
|
|
|
|
|
|
|
|
|
|
293 |
{
|
294 |
+
if (this.parentElementType == 'li')
|
295 |
+
{
|
296 |
+
$(prefix + street1).up(this.parentElementType).insert({before: '<li id="' + prefix +'showcase" class="wide"><div class="input-box"><h4 class="pcnl-showcase">'+ PCNLAPI_CONFIG.translations.apiShowcase.escapeHTML() +'</h4>'+ map + info + '</div></li>'});
|
297 |
+
}
|
298 |
+
else if (this.parentElementType == 'tr')
|
299 |
+
{
|
300 |
+
// We're probably in the admin
|
301 |
+
$(prefix + street1).up(this.parentElementType).insert({before: '<tr id="' + prefix + 'showcase"><td class="label">'+ PCNLAPI_CONFIG.translations.apiShowcase.escapeHTML() +'</label></td><td class="value"><h4 class="pcnl-showcase">'+ PCNLAPI_CONFIG.translations.apiShowcase.escapeHTML() +'</h4>'+ info + '</td></tr>'});
|
302 |
+
}
|
303 |
+
else
|
304 |
+
{
|
305 |
+
// Assume 'div' elements
|
306 |
+
$(prefix + street1).up(this.parentElementType).insert({before: '<div id="' + prefix + 'showcase"><h4 class="pcnl-showcase">'+ PCNLAPI_CONFIG.translations.apiShowcase.escapeHTML() +'</h4>'+ info + '</div>'});
|
307 |
+
}
|
308 |
}
|
309 |
}
|
310 |
if (PCNLAPI_CONFIG.debug)
|
314 |
|
315 |
var info = this.getFieldListHtml(data.debugInfo, 'pcnl-debug');
|
316 |
|
317 |
+
if ($(prefix + street1).up(this.parentElementType))
|
|
|
|
|
|
|
|
|
|
|
318 |
{
|
319 |
+
if (this.parentElementType == 'li')
|
320 |
+
{
|
321 |
+
$(prefix + street1).up(this.parentElementType).insert({before: '<li id="' + prefix +'debug" class="wide"><div class="input-box"><h4 class="pcnl-debug">'+ PCNLAPI_CONFIG.translations.apiDebug.escapeHTML() +'</h4>'+ info + '</div></li>'});
|
322 |
+
}
|
323 |
+
else if (this.parentElementType == 'tr')
|
324 |
+
{
|
325 |
+
// We're probably in the admin
|
326 |
+
$(prefix + street1).up(this.parentElementType).insert({before: '<tr id="' + prefix + 'debug"><td class="label">'+ PCNLAPI_CONFIG.translations.apiDebug.escapeHTML() +'</label></td><td class="value"><h4 class="pcnl-debug">'+ PCNLAPI_CONFIG.translations.apiDebug.escapeHTML() +'</h4>'+ info + '</td></tr>'});
|
327 |
+
}
|
328 |
+
else
|
329 |
+
{
|
330 |
+
// Assume 'div' elements
|
331 |
+
$(prefix + street1).up(this.parentElementType).insert({before: '<div id="' + prefix +'debug" class="full"><div class="input-box"><h4 class="pcnl-debug">'+ PCNLAPI_CONFIG.translations.apiDebug.escapeHTML() +'</h4>'+ info + '</div></div>'});
|
332 |
+
}
|
333 |
}
|
334 |
}
|
335 |
|
336 |
// Remove any existing error messages
|
337 |
this.removeValidationMessages(prefix);
|
338 |
|
339 |
+
if (data.postcode !== undefined)
|
340 |
{
|
341 |
// Set data from request on form fields
|
342 |
var postcodeChange = false;
|
408 |
this.removeHousenumberAddition(prefix);
|
409 |
}
|
410 |
}
|
411 |
+
else if (data.message !== undefined)
|
412 |
{
|
413 |
// Address check returned an error
|
414 |
|
431 |
|
432 |
// Add support for syncing Billing & Shipping
|
433 |
if (prefix == 'billing:' && $('shipping:' + postcodeFieldId)) {
|
434 |
+
// 'shipping' is a global object created on most checkout pages
|
435 |
if (typeof shipping != 'undefined') {
|
436 |
if ($('shipping:same_as_billing') && $('shipping:same_as_billing').checked) {
|
437 |
shipping.syncWithBilling();
|
453 |
|
454 |
if (!$(prefix +'postcode_input:wrapper'))
|
455 |
{
|
456 |
+
if ($$('table.form-list').length > 0 && $(prefix + postcodeFieldId).parentNode.tagName == 'TD')
|
457 |
{
|
458 |
+
// We're probably in the admin, slightly different logic than the frontend checkout forms
|
459 |
+
|
460 |
+
this.parentElementType = 'tr';
|
461 |
+
|
462 |
if (PCNLAPI_CONFIG.adminValidationDisabled)
|
463 |
{
|
464 |
return;
|
536 |
}
|
537 |
$(prefix + 'country_id').up('li').insert({before: '<li id="' + prefix + 'postcode_input:output" class="pcnl-hidden-field"><div class="input-box"><label>'+ PCNLAPI_CONFIG.translations.outputLabel +'</label><div id="' + prefix + 'postcode_output" class="pcnl-address-text"></div></div></li>'});
|
538 |
}
|
539 |
+
else if ($(document.body).hasClassName('checkout-onestep-index') && $('easycheckout-login-form'))
|
540 |
+
{
|
541 |
+
// GrafischDirect One Step Checkout
|
542 |
+
|
543 |
+
this.parentElementType = 'div.line';
|
544 |
+
|
545 |
+
if (!$(prefix +'postcode_input:info'))
|
546 |
+
{
|
547 |
+
$(prefix + street1).up('div.line').insert({before: '<div id="' + prefix + 'postcode_input:info" class="pcnl-info line"><div class="input-box"><label class="pcnl-info-label">'+ PCNLAPI_CONFIG.translations.infoLabel +'</label><div class="pcnl-info-text">'+ PCNLAPI_CONFIG.translations.infoText +'</div></div></div>'});
|
548 |
+
}
|
549 |
+
$(prefix + street1).up('div.line').insert({before: '<div id="' + prefix + 'postcode_input:wrapper" class="line"><div class="input-postcode left"><label for="' + prefix + 'postcode_input" class="required">'+ PCNLAPI_CONFIG.translations.postcodeInputLabel +'<span class="required">*</span></label><div class="input-box"><input type="text" title="'+ PCNLAPI_CONFIG.translations.postcodeInputTitle +'" id="' + prefix + 'postcode_input" value="" class="input-text required-entry" /></div></div><div class="input-postcode pcnl-input-housenumber right"><label for="' + prefix + 'postcode_housenumber" class="required">'+ PCNLAPI_CONFIG.translations.houseNumberLabel +' <span class="required">*</span></label><div class="input-box"><input type="text" title="'+ PCNLAPI_CONFIG.translations.houseNumberTitle +'" name="billing[postcode_housenumber]" id="' + prefix + 'postcode_housenumber" value="" class="input-text pcnl-input-text-half required-entry" /></div></div></div>'});
|
550 |
+
if (!$(prefix +'postcode_input:checkbox'))
|
551 |
+
{
|
552 |
+
$(prefix + street1).up('div.line').insert({before: '<div id="' + prefix + 'postcode_input:checkbox" class="pcnl-manual-checkbox line"><div class="full"><input type="checkbox" title="'+ PCNLAPI_CONFIG.translations.postcodeInputTitle +'" id="' + prefix + 'postcode_input_checkbox" value="" class="checkbox " /><label for="' + prefix + 'postcode_input_checkbox"><label for="' + prefix + 'postcode_input:checkbox">'+ PCNLAPI_CONFIG.translations.manualInputText +'</label></div></div>'});
|
553 |
+
$(prefix + 'postcode_input_checkbox').observe('click', function () { pcnlapi.toggleCountryPostcode(prefix, postcodeFieldId, countryFieldId, street1, street2, street3, street4); });
|
554 |
+
}
|
555 |
+
$(prefix + street1).up('div.line').insert({before: '<div id="' + prefix + 'postcode_input:output" class="pcnl-hidden-field line"><div class="input-box"><label>'+ PCNLAPI_CONFIG.translations.outputLabel +'</label><div id="' + prefix + 'postcode_output" class="pcnl-address-text"></div></div></div>'});
|
556 |
+
}
|
557 |
else if ($(document.body).hasClassName('checkout-onestep-index'))
|
558 |
{
|
559 |
// FME One Step Checkout
|
574 |
{
|
575 |
// IWD Free One Page / Step Checkout
|
576 |
|
577 |
+
this.parentElementType = 'div.full, div.two_fields';
|
578 |
+
|
579 |
if (!$(prefix +'postcode_input:info'))
|
580 |
{
|
581 |
$(prefix + street1).up('div.full').insert({before: '<div id="' + prefix + 'postcode_input:info" class="full"><div><label class="pcnl-info-label">'+ PCNLAPI_CONFIG.translations.infoLabel +'</label><div class="pcnl-info-text">'+ PCNLAPI_CONFIG.translations.infoText +'</div></div></div>'});
|
647 |
var housenumber_addition = '';
|
648 |
if (PCNLAPI_CONFIG.useStreet2AsHouseNumber && $(prefix + street2))
|
649 |
{
|
650 |
+
housenumber_match = $(prefix + street2).getValue().match('^('+ this.REGEXP_HOUSENUMBER +')([^0-9a-zA-Z]*('+ this.REGEXP_HOUSENUMBER_ADDITION +'))?\\s*$');
|
651 |
if (housenumber_match)
|
652 |
{
|
653 |
housenumber = housenumber_match[1].trim();
|
654 |
+
housenumber_addition = housenumber_match[3] === undefined ? '' : housenumber_match[3].trim();
|
655 |
}
|
656 |
}
|
657 |
else
|
658 |
{
|
659 |
+
housenumber_match = $(prefix + street1).getValue().match('^('+ this.REGEXP_STREET +')\\s+('+ this.REGEXP_HOUSENUMBER +')([^0-9a-zA-Z]*('+ this.REGEXP_HOUSENUMBER_ADDITION +'))?\\s*$');
|
660 |
if (housenumber_match)
|
661 |
{
|
662 |
housenumber = housenumber_match[2].trim();
|
663 |
+
housenumber_addition = housenumber_match[4] === undefined ? '' : housenumber_match[4].trim();
|
664 |
}
|
665 |
}
|
666 |
|
724 |
prefix + street4,
|
725 |
prefix + 'city',
|
726 |
prefix + 'region',
|
727 |
+
prefix + countryFieldId,
|
728 |
]);
|
729 |
+
if (PCNLAPI_CONFIG.neverHideCountry)
|
730 |
{
|
731 |
+
this.showFields([prefix + countryFieldId]);
|
732 |
}
|
733 |
|
734 |
// Set empty, will be corrected later
|
803 |
options += '<option value="'+ (value == '' ? '__none__' : value.escapeHTML()) +'">'+ (value == '' ? PCNLAPI_CONFIG.translations.noAdditionSelect : value ).escapeHTML() +'</option>';
|
804 |
});
|
805 |
|
806 |
+
if (this.parentElementType == 'tr')
|
807 |
{
|
808 |
// We're probably in the admin
|
809 |
+
$(prefix + 'postcode_housenumber').up(this.parentElementType).insert({after: '<tr id="' + prefix +'postcode_housenumber_addition:wrapper"><td class="label"><label for="'+ prefix +'postcode_housenumber_addition">'+ PCNLAPI_CONFIG.translations.houseNumberAdditionLabel +' <span class="required">*</span></label></td><td class="value"><select title="'+ PCNLAPI_CONFIG.translations.houseNumberAdditionTitle +'" name="'+ prefix + 'postcode_housenumber_addition" id="' + prefix + 'postcode_housenumber_addition" class="select">'+ options +'</select></td></tr>'});
|
810 |
}
|
811 |
else
|
812 |
{
|
813 |
// We're probably in the frontend
|
814 |
$(prefix + 'postcode_housenumber').insert({after: '<select title="'+ PCNLAPI_CONFIG.translations.houseNumberAdditionTitle +'" name="'+ prefix + 'postcode_housenumber_addition" id="' + prefix + 'postcode_housenumber_addition" class="validate-select pcnl-input-text-half">'+ options +'</select>'});
|
815 |
+
$(prefix + 'postcode_housenumber').up(this.parentElementType).addClassName('pcnl-with-addition');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
816 |
}
|
817 |
|
818 |
$(prefix +'postcode_housenumber_addition').observe('change', function(e) { pcnlapi.lookupPostcode(prefix, postcodeFieldId, countryFieldId, street1, street2, street3, street4, e); });
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>PostcodeNl_Api</name>
|
4 |
-
<version>1.0.
|
5 |
<stability>stable</stability>
|
6 |
<license>Simplified BSD License</license>
|
7 |
<channel>community</channel>
|
@@ -16,11 +16,14 @@
|
|
16 |

|
17 |
The postcode Magento plugin from Postcode.nl is free of charge, based on a Fair-Use policy. The use of the Postcode.nl Magento plugin is subject to our Terms and Conditions.</description>
|
18 |
<notes>Changes:
|
19 |
-
-
|
|
|
|
|
|
|
20 |
<authors><author><name>Postcode.nl Technical Support</name><user>auto-converted</user><email>tech@postcode.nl</email></author></authors>
|
21 |
-
<date>2013-03-
|
22 |
-
<time>14:
|
23 |
-
<contents><target name="magecommunity"><dir name="PostcodeNl"><dir name="Api"><dir name="Block"><file name="Jsinit.php" hash="79bb826a50ce0cf4f87cc2f958bfafa1"/></dir><dir name="Helper"><file name="Data.php" hash="
|
24 |
<compatible/>
|
25 |
<dependencies/>
|
26 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>PostcodeNl_Api</name>
|
4 |
+
<version>1.0.7.0</version>
|
5 |
<stability>stable</stability>
|
6 |
<license>Simplified BSD License</license>
|
7 |
<channel>community</channel>
|
16 |

|
17 |
The postcode Magento plugin from Postcode.nl is free of charge, based on a Fair-Use policy. The use of the Postcode.nl Magento plugin is subject to our Terms and Conditions.</description>
|
18 |
<notes>Changes:
|
19 |
+
- Improved 'Never hide country selector' option to also work for regular checkouts
|
20 |
+
- Added provisional support for GrafischDirect One Step Checkout
|
21 |
+
- Improved address housenumber addition user input matching
|
22 |
+
- More Magento coding-standards compliant</notes>
|
23 |
<authors><author><name>Postcode.nl Technical Support</name><user>auto-converted</user><email>tech@postcode.nl</email></author></authors>
|
24 |
+
<date>2013-03-21</date>
|
25 |
+
<time>14:33:42</time>
|
26 |
+
<contents><target name="magecommunity"><dir name="PostcodeNl"><dir name="Api"><dir name="Block"><file name="Jsinit.php" hash="79bb826a50ce0cf4f87cc2f958bfafa1"/></dir><dir name="Helper"><file name="Data.php" hash="54281c0641b2123bbe885a3800f8c789"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="PcnlController.php" hash="a72395c695188f3a1aff9eb7dba4091d"/></dir><file name="JsonController.php" hash="180f25dccbe40710fea4bbe2a4c4ee8a"/></dir><dir name="etc"><file name="adminhtml.xml" hash="207cb9b9ca018f5e3d1b684e6e8615eb"/><file name="config.xml" hash="f7f0cd6c14f0a933a92383c0c78487d8"/><file name="system.xml" hash="42074f28167cce0aadce2cafa183d9cf"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="postcodenl"><dir name="api"><file name="lookup.xml" hash="4d99ee42b7bcfcff9dcfb41dcb51c838"/></dir></dir></dir><dir name="template"><dir name="postcodenl"><dir name="api"><file name="jsinit.phtml" hash="e08a3ce7a48801bf997dbd4f6743b53f"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><dir name="postcodenl"><dir name="api"><file name="lookup.xml" hash="6ec9c69d8cab0db75011fce8e478f6ee"/></dir></dir></dir><dir name="template"><dir name="postcodenl"><dir name="api"><file name="jsinit.phtml" hash="339610e5950a53c3966d80cccf9bede4"/></dir></dir></dir></dir></dir><dir name="base"><dir name="default"><dir name="layout"><dir name="postcodenl"><dir name="api"><file name="lookup.xml" hash="f59eb1b9834a5a71c07ce55d7f98fbd8"/></dir></dir></dir><dir name="template"><dir name="postcodenl"><dir name="api"><file name="jsinit.phtml" hash="339610e5950a53c3966d80cccf9bede4"/></dir></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="PostcodeNl_Api.csv" hash="e906b29f07ffd60defa504be687f8238"/></dir><dir name="nl_NL"><file name="PostcodeNl_Api.csv" hash="a87ec754c45a12ea048792503b5d6dcd"/></dir></target><target name="mageweb"><dir name="js"><dir name="postcodenl"><dir name="api"><file name="lookup.js" hash="ae79418caa3b13b52567a8308becf94b"/></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="postcodenl"><dir name="api"><dir name="css"><file name="lookup.css" hash="c58103b505f8bcdf55cea1159ca21e27"/></dir><dir name="images"><file name="postcode-logo.png" hash="da02bc29be1057a0201e63f81ee4bd02"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="postcodenl"><dir name="api"><dir name="css"><file name="lookup.css" hash="def30283baa30441588be03adb47feb6"/></dir><dir name="images"><file name="postcode-logo.png" hash="da02bc29be1057a0201e63f81ee4bd02"/></dir></dir></dir></dir></dir><dir name="base"><dir name="default"><dir name="postcodenl"><dir name="api"><dir name="css"><file name="lookup.css" hash="54afa1de84fddeece289b20d817f7e13"/></dir><dir name="images"><file name="postcode-logo.png" hash="da02bc29be1057a0201e63f81ee4bd02"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="PostcodeNl_Api.xml" hash="feeaf95128ffe4ad109ed8b0b8bc85ab"/></dir></target></contents>
|
27 |
<compatible/>
|
28 |
<dependencies/>
|
29 |
</package>
|
skin/frontend/base/default/postcodenl/api/css/lookup.css
CHANGED
@@ -80,7 +80,7 @@ dl.pcnl-showcase dd, dl.pcnl-debug dd {
|
|
80 |
margin-left: 20px;
|
81 |
}
|
82 |
|
83 |
-
/* OneStepCheckout styling */
|
84 |
div.checkoutcontainer div.pcnl-input-housenumber {
|
85 |
width: 60%;
|
86 |
}
|
@@ -149,4 +149,4 @@ body.onestepcheckout-index-index .onepage .form-list .pcnl-apptha-checkbox label
|
|
149 |
/* IWD One Step Checkout */
|
150 |
body.onepagecheckout-index-index .pcnl-manual-checkbox {
|
151 |
clear: both; /* IE 7/9 fix */
|
152 |
-
}
|
80 |
margin-left: 20px;
|
81 |
}
|
82 |
|
83 |
+
/* OneStepCheckout(.com) styling */
|
84 |
div.checkoutcontainer div.pcnl-input-housenumber {
|
85 |
width: 60%;
|
86 |
}
|
149 |
/* IWD One Step Checkout */
|
150 |
body.onepagecheckout-index-index .pcnl-manual-checkbox {
|
151 |
clear: both; /* IE 7/9 fix */
|
152 |
+
}
|