Version Notes
Release History
v0.2.0
* Major Structural Rework
v0.1.4
* Fix: better handling of region dropdowns
v0.1.3
* Fix: added check for google CDN state.
v0.1.2
* Stable release
v0.1.1
* Fix: some gmaps suggestions were considered premise level when they were not.
v0.1.0
* Initial Release
Download this release
Release Info
Developer | Crafty Clicks |
Extension | Crafty_Clicks_International_Address_Validation |
Version | 0.2.0 |
Comparing to | |
See all releases |
Code changes from version 0.1.6 to 0.2.0
- app/code/community/Craftyclicks/Googleaddressvalidate/Helper/Data.php +5 -0
- app/code/{local/CraftyClicksValidate → community/Craftyclicks/Googleaddressvalidate}/controllers/AjaxController.php +2 -3
- app/code/community/Craftyclicks/Googleaddressvalidate/data/craftyclicks_googleaddressvalidate_setup/data-upgrade-0.1.6-0.2.0.php +28 -0
- app/code/community/Craftyclicks/Googleaddressvalidate/etc/config.xml +96 -0
- app/code/{local/CraftyClicksValidate → community/Craftyclicks/Googleaddressvalidate}/etc/system.xml +29 -16
- app/code/local/CraftyClicksValidate/Helper/Data.php +0 -7
- app/code/local/CraftyClicksValidate/etc/config.xml +0 -61
- app/design/frontend/base/default/layout/{craftyclicks_validate.xml → craftyclicks_googleaddressvalidate.xml} +4 -4
- app/design/frontend/base/default/template/craftyclicks/googleaddressvalidate/post_checkout.phtml +347 -0
- app/design/frontend/base/default/template/craftyclicksvalidate/post_checkout.phtml +0 -343
- app/etc/modules/CraftyClicksValidate.xml +2 -1
- app/etc/modules/Craftyclicks_Googleaddressvalidate.xml +10 -0
- package.xml +6 -9
- skin/frontend/base/default/css/{craftyclicksvalidate → craftyclicks/googleaddressvalidate}/validate.css +0 -0
- skin/frontend/base/default/css/{craftyclicksvalidate → craftyclicks/googleaddressvalidate}/validate_old.css +0 -0
- skin/frontend/base/default/images/{craftyclicksvalidate → craftyclicks/googleaddressvalidate}/crafty_validate_busy.gif +0 -0
app/code/community/Craftyclicks/Googleaddressvalidate/Helper/Data.php
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Craftyclicks_Googleaddressvalidate_Helper_Data extends Mage_Core_Helper_Abstract
|
3 |
+
{
|
4 |
+
|
5 |
+
}
|
app/code/{local/CraftyClicksValidate → community/Craftyclicks/Googleaddressvalidate}/controllers/AjaxController.php
RENAMED
@@ -1,6 +1,5 @@
|
|
1 |
<?php
|
2 |
-
class
|
3 |
-
|
4 |
public function updateAction(){
|
5 |
$order_id = Mage::getSingleton('checkout/session')->getLastRealOrderId();
|
6 |
//$_GET["order_id"];
|
@@ -38,4 +37,4 @@ class CraftyClicksValidate_AjaxController extends Mage_Core_Controller_Front_Act
|
|
38 |
}
|
39 |
|
40 |
}
|
41 |
-
}
|
1 |
<?php
|
2 |
+
class Craftyclicks_Googleaddressvalidate_AjaxController extends Mage_Core_Controller_Front_Action{
|
|
|
3 |
public function updateAction(){
|
4 |
$order_id = Mage::getSingleton('checkout/session')->getLastRealOrderId();
|
5 |
//$_GET["order_id"];
|
37 |
}
|
38 |
|
39 |
}
|
40 |
+
}
|
app/code/community/Craftyclicks/Googleaddressvalidate/data/craftyclicks_googleaddressvalidate_setup/data-upgrade-0.1.6-0.2.0.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$configAccess = new Mage_Core_Model_Config();
|
3 |
+
$oldCfg = Mage::getStoreConfig('general');
|
4 |
+
|
5 |
+
if(isset($oldCfg['craftyclicksvalidate'])){
|
6 |
+
//old plugin was set
|
7 |
+
//transfer old config into new one.
|
8 |
+
$values = array(
|
9 |
+
"active",
|
10 |
+
"loading_image",
|
11 |
+
"title",
|
12 |
+
"description_1",
|
13 |
+
"description_2",
|
14 |
+
"finish_text",
|
15 |
+
"gmaps",
|
16 |
+
"region_dropdown");
|
17 |
+
$data = array();
|
18 |
+
//check if every old cfg exists. (some older versions might not have all of these options)
|
19 |
+
foreach($values as $val){
|
20 |
+
if(isset($oldCfg['craftyclicksvalidate'][$val])){
|
21 |
+
$data[$val] = $oldCfg['craftyclicksvalidate'][$val];
|
22 |
+
}
|
23 |
+
}
|
24 |
+
foreach($data as $k=>$v){
|
25 |
+
$configAccess->saveConfig('googleaddressvalidate/general/'.$k,$v, 'default', 0);
|
26 |
+
}
|
27 |
+
}
|
28 |
+
?>
|
app/code/community/Craftyclicks/Googleaddressvalidate/etc/config.xml
ADDED
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Crafty Clicks - Google Address Validate
|
5 |
+
*
|
6 |
+
* @category CraftyClicks
|
7 |
+
* @package CraftyClicks
|
8 |
+
* @copyright CraftyClicks.co.uk
|
9 |
+
*/
|
10 |
+
-->
|
11 |
+
|
12 |
+
<config>
|
13 |
+
<modules>
|
14 |
+
<Craftyclicks_Googleaddressvalidate>
|
15 |
+
<version>0.2.0</version>
|
16 |
+
</Craftyclicks_Googleaddressvalidate>
|
17 |
+
</modules>
|
18 |
+
|
19 |
+
<global>
|
20 |
+
<helpers>
|
21 |
+
<googleaddressvalidate>
|
22 |
+
<class>Craftyclicks_Googleaddressvalidate_Helper</class>
|
23 |
+
</googleaddressvalidate>
|
24 |
+
</helpers>
|
25 |
+
</global>
|
26 |
+
|
27 |
+
<default>
|
28 |
+
<googleaddressvalidate>
|
29 |
+
<general>
|
30 |
+
<active>0</active>
|
31 |
+
<loading_image></loading_image>
|
32 |
+
<title>Is your address correct?</title>
|
33 |
+
<description_1>We think there's an issue with your delivery address. Please review it.</description_1>
|
34 |
+
<description_2>If you think the address is correct, please ignore this message.</description_2>
|
35 |
+
<finish_text>Thank you! We updated your shipping address.</finish_text>
|
36 |
+
<gmaps>1</gmaps>
|
37 |
+
<region_dropdown>0</region_dropdown>
|
38 |
+
</general>
|
39 |
+
</googleaddressvalidate>
|
40 |
+
</default>
|
41 |
+
|
42 |
+
<frontend>
|
43 |
+
<layout>
|
44 |
+
<updates>
|
45 |
+
<craftyclicks_googleaddressvalidate module="Craftyclicks_Googleaddressvalidate">
|
46 |
+
<file>craftyclicks_googleaddressvalidate.xml</file>
|
47 |
+
</craftyclicks_googleaddressvalidate>
|
48 |
+
</updates>
|
49 |
+
</layout>
|
50 |
+
<routers>
|
51 |
+
<googleaddressvalidate>
|
52 |
+
<use>standard</use>
|
53 |
+
<args>
|
54 |
+
<module>Craftyclicks_Googleaddressvalidate</module>
|
55 |
+
<frontName>googleaddressvalidate</frontName>
|
56 |
+
</args>
|
57 |
+
</googleaddressvalidate>
|
58 |
+
</routers>
|
59 |
+
</frontend>
|
60 |
+
|
61 |
+
<adminhtml>
|
62 |
+
<acl>
|
63 |
+
<resources>
|
64 |
+
<all>
|
65 |
+
<title>Allow Everything</title>
|
66 |
+
</all>
|
67 |
+
<admin>
|
68 |
+
<children>
|
69 |
+
<system>
|
70 |
+
<children>
|
71 |
+
<config>
|
72 |
+
<children>
|
73 |
+
<googleaddressvalidate translate="title" module="googleaddressvalidate">
|
74 |
+
<title>googleaddressvalidate - All</title>
|
75 |
+
</googleaddressvalidate>
|
76 |
+
</children>
|
77 |
+
</config>
|
78 |
+
</children>
|
79 |
+
</system>
|
80 |
+
</children>
|
81 |
+
</admin>
|
82 |
+
</resources>
|
83 |
+
</acl>
|
84 |
+
</adminhtml>
|
85 |
+
|
86 |
+
<global>
|
87 |
+
<resources>
|
88 |
+
<craftyclicks_googleaddressvalidate_setup>
|
89 |
+
<setup>
|
90 |
+
<module>Craftyclicks_Googleaddressvalidate</module>
|
91 |
+
</setup>
|
92 |
+
</craftyclicks_googleaddressvalidate_setup>
|
93 |
+
</resources>
|
94 |
+
</global>
|
95 |
+
|
96 |
+
</config>
|
app/code/{local/CraftyClicksValidate → community/Craftyclicks/Googleaddressvalidate}/etc/system.xml
RENAMED
@@ -1,15 +1,29 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
-
|
3 |
<config>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
<sections>
|
5 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
<groups>
|
7 |
-
<
|
8 |
-
<label>Crafty Clicks - Address Validate</label>
|
|
|
9 |
<sort_order>124</sort_order>
|
10 |
<show_in_default>1</show_in_default>
|
11 |
<show_in_website>1</show_in_website>
|
12 |
-
<show_in_store>
|
13 |
<fields>
|
14 |
<active translate="label">
|
15 |
<label>Enabled</label>
|
@@ -18,7 +32,7 @@
|
|
18 |
<sort_order>1</sort_order>
|
19 |
<show_in_default>1</show_in_default>
|
20 |
<show_in_website>1</show_in_website>
|
21 |
-
<show_in_store>
|
22 |
</active>
|
23 |
|
24 |
<loading_image translate="label">
|
@@ -27,7 +41,7 @@
|
|
27 |
<sort_order>12</sort_order>
|
28 |
<show_in_default>1</show_in_default>
|
29 |
<show_in_website>1</show_in_website>
|
30 |
-
<show_in_store>
|
31 |
<comment>Here you can enter an image file name to use as the loading image while the address validation is working.</comment>
|
32 |
</loading_image>
|
33 |
|
@@ -37,7 +51,7 @@
|
|
37 |
<sort_order>35</sort_order>
|
38 |
<show_in_default>1</show_in_default>
|
39 |
<show_in_website>1</show_in_website>
|
40 |
-
<show_in_store>
|
41 |
<comment>Title of the block.</comment>
|
42 |
</title>
|
43 |
|
@@ -47,7 +61,7 @@
|
|
47 |
<sort_order>36</sort_order>
|
48 |
<show_in_default>1</show_in_default>
|
49 |
<show_in_website>1</show_in_website>
|
50 |
-
<show_in_store>
|
51 |
<comment>Description of the block.</comment>
|
52 |
</description_1>
|
53 |
|
@@ -57,7 +71,7 @@
|
|
57 |
<sort_order>37</sort_order>
|
58 |
<show_in_default>1</show_in_default>
|
59 |
<show_in_website>1</show_in_website>
|
60 |
-
<show_in_store>
|
61 |
<comment>Sub-Description of the block.</comment>
|
62 |
</description_2>
|
63 |
|
@@ -67,7 +81,7 @@
|
|
67 |
<sort_order>38</sort_order>
|
68 |
<show_in_default>1</show_in_default>
|
69 |
<show_in_website>1</show_in_website>
|
70 |
-
<show_in_store>
|
71 |
<comment>Text after successful update.</comment>
|
72 |
</finish_text>
|
73 |
|
@@ -78,7 +92,7 @@
|
|
78 |
<sort_order>40</sort_order>
|
79 |
<show_in_default>1</show_in_default>
|
80 |
<show_in_website>1</show_in_website>
|
81 |
-
<show_in_store>
|
82 |
<comment>Display Google Maps. Required for free licensing.</comment>
|
83 |
</gmaps>
|
84 |
|
@@ -89,14 +103,13 @@
|
|
89 |
<sort_order>39</sort_order>
|
90 |
<show_in_default>1</show_in_default>
|
91 |
<show_in_website>1</show_in_website>
|
92 |
-
<show_in_store>
|
93 |
<comment>Allow manual region entry of custom regions.</comment>
|
94 |
</region_dropdown>
|
95 |
|
96 |
</fields>
|
97 |
-
|
98 |
-
</craftyclicksvalidate>
|
99 |
</groups>
|
100 |
-
</
|
101 |
</sections>
|
102 |
</config>
|
1 |
<?xml version="1.0"?>
|
|
|
2 |
<config>
|
3 |
+
<tabs>
|
4 |
+
<craftyclicks translate="label" module="googleaddressvalidate">
|
5 |
+
<label><![CDATA[<img style="margin: 4px 4px 4px 0px;" src="https://craftyclicks.co.uk/assets/magento/crafty-logo.png" alt="Crafty Clicks" border="0" />]]></label>
|
6 |
+
<sort_order>101</sort_order>
|
7 |
+
</craftyclicks>
|
8 |
+
</tabs>
|
9 |
+
|
10 |
<sections>
|
11 |
+
<googleaddressvalidate translate="label" module="googleaddressvalidate">
|
12 |
+
<label>Google Address Validate</label>
|
13 |
+
<tab>craftyclicks</tab>
|
14 |
+
<sort_order>300</sort_order>
|
15 |
+
<show_in_default>1</show_in_default>
|
16 |
+
<show_in_website>1</show_in_website>
|
17 |
+
<show_in_store>1</show_in_store>
|
18 |
+
|
19 |
<groups>
|
20 |
+
<general translate="label" module="googleaddressvalidate">
|
21 |
+
<label>Crafty Clicks - Google Address Validate</label>
|
22 |
+
<frontend_type>text</frontend_type>
|
23 |
<sort_order>124</sort_order>
|
24 |
<show_in_default>1</show_in_default>
|
25 |
<show_in_website>1</show_in_website>
|
26 |
+
<show_in_store>1</show_in_store>
|
27 |
<fields>
|
28 |
<active translate="label">
|
29 |
<label>Enabled</label>
|
32 |
<sort_order>1</sort_order>
|
33 |
<show_in_default>1</show_in_default>
|
34 |
<show_in_website>1</show_in_website>
|
35 |
+
<show_in_store>1</show_in_store>
|
36 |
</active>
|
37 |
|
38 |
<loading_image translate="label">
|
41 |
<sort_order>12</sort_order>
|
42 |
<show_in_default>1</show_in_default>
|
43 |
<show_in_website>1</show_in_website>
|
44 |
+
<show_in_store>1</show_in_store>
|
45 |
<comment>Here you can enter an image file name to use as the loading image while the address validation is working.</comment>
|
46 |
</loading_image>
|
47 |
|
51 |
<sort_order>35</sort_order>
|
52 |
<show_in_default>1</show_in_default>
|
53 |
<show_in_website>1</show_in_website>
|
54 |
+
<show_in_store>1</show_in_store>
|
55 |
<comment>Title of the block.</comment>
|
56 |
</title>
|
57 |
|
61 |
<sort_order>36</sort_order>
|
62 |
<show_in_default>1</show_in_default>
|
63 |
<show_in_website>1</show_in_website>
|
64 |
+
<show_in_store>1</show_in_store>
|
65 |
<comment>Description of the block.</comment>
|
66 |
</description_1>
|
67 |
|
71 |
<sort_order>37</sort_order>
|
72 |
<show_in_default>1</show_in_default>
|
73 |
<show_in_website>1</show_in_website>
|
74 |
+
<show_in_store>1</show_in_store>
|
75 |
<comment>Sub-Description of the block.</comment>
|
76 |
</description_2>
|
77 |
|
81 |
<sort_order>38</sort_order>
|
82 |
<show_in_default>1</show_in_default>
|
83 |
<show_in_website>1</show_in_website>
|
84 |
+
<show_in_store>1</show_in_store>
|
85 |
<comment>Text after successful update.</comment>
|
86 |
</finish_text>
|
87 |
|
92 |
<sort_order>40</sort_order>
|
93 |
<show_in_default>1</show_in_default>
|
94 |
<show_in_website>1</show_in_website>
|
95 |
+
<show_in_store>1</show_in_store>
|
96 |
<comment>Display Google Maps. Required for free licensing.</comment>
|
97 |
</gmaps>
|
98 |
|
103 |
<sort_order>39</sort_order>
|
104 |
<show_in_default>1</show_in_default>
|
105 |
<show_in_website>1</show_in_website>
|
106 |
+
<show_in_store>1</show_in_store>
|
107 |
<comment>Allow manual region entry of custom regions.</comment>
|
108 |
</region_dropdown>
|
109 |
|
110 |
</fields>
|
111 |
+
</general>
|
|
|
112 |
</groups>
|
113 |
+
</googleaddressvalidate>
|
114 |
</sections>
|
115 |
</config>
|
app/code/local/CraftyClicksValidate/Helper/Data.php
DELETED
@@ -1,7 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
class CraftyClicksValidate_Helper_Data extends Mage_Core_Helper_Abstract
|
5 |
-
{
|
6 |
-
|
7 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/local/CraftyClicksValidate/etc/config.xml
DELETED
@@ -1,61 +0,0 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<!--
|
3 |
-
/**
|
4 |
-
* Crafty Clicks - Address Finder
|
5 |
-
*
|
6 |
-
* @category CraftyClicks
|
7 |
-
* @package CraftyClicks
|
8 |
-
* @copyright CraftyClicks.co.uk
|
9 |
-
*/
|
10 |
-
-->
|
11 |
-
|
12 |
-
<config>
|
13 |
-
<modules>
|
14 |
-
<CraftyClicksValidate>
|
15 |
-
<version>0.1.6</version>
|
16 |
-
</CraftyClicksValidate>
|
17 |
-
</modules>
|
18 |
-
|
19 |
-
<frontend>
|
20 |
-
<layout>
|
21 |
-
<updates>
|
22 |
-
<craftyclicksvalidate>
|
23 |
-
<file>craftyclicks_validate.xml</file>
|
24 |
-
</craftyclicksvalidate>
|
25 |
-
</updates>
|
26 |
-
</layout>
|
27 |
-
<routers>
|
28 |
-
<craftyclicksvalidate>
|
29 |
-
<use>standard</use>
|
30 |
-
<args>
|
31 |
-
<module>CraftyClicksValidate</module>
|
32 |
-
<frontName>craftyclicksvalidate</frontName>
|
33 |
-
</args>
|
34 |
-
</craftyclicksvalidate>
|
35 |
-
</routers>
|
36 |
-
</frontend>
|
37 |
-
|
38 |
-
|
39 |
-
<global>
|
40 |
-
<helpers>
|
41 |
-
<craftyclicksvalidate>
|
42 |
-
<class>CraftyClicksValidate_Helper</class>
|
43 |
-
</craftyclicksvalidate>
|
44 |
-
</helpers>
|
45 |
-
</global>
|
46 |
-
<default>
|
47 |
-
<general>
|
48 |
-
<craftyclicksvalidate>
|
49 |
-
<active>0</active>
|
50 |
-
<loading_image></loading_image>
|
51 |
-
<title>Is your address correct?</title>
|
52 |
-
<description_1>We think there's an issue with your delivery address. Please review it.</description_1>
|
53 |
-
<description_2>If you think the address is correct, please ignore this message.</description_2>
|
54 |
-
<finish_text>Thank you! We updated your shipping address.</finish_text>
|
55 |
-
<gmaps>1</gmaps>
|
56 |
-
<region_dropdown>0</region_dropdown>
|
57 |
-
</craftyclicksvalidate>
|
58 |
-
</general>
|
59 |
-
</default>
|
60 |
-
|
61 |
-
</config>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/design/frontend/base/default/layout/{craftyclicks_validate.xml → craftyclicks_googleaddressvalidate.xml}
RENAMED
@@ -11,13 +11,13 @@
|
|
11 |
|
12 |
<layout>
|
13 |
<!-- Ajax Time -->
|
14 |
-
<
|
15 |
-
<block type="
|
16 |
-
</
|
17 |
|
18 |
<checkout_onepage_success>
|
19 |
<reference name="head">
|
20 |
-
<block type="page/html" name="craftyclicks_postcheck" template="
|
21 |
</reference>
|
22 |
</checkout_onepage_success>
|
23 |
</layout>
|
11 |
|
12 |
<layout>
|
13 |
<!-- Ajax Time -->
|
14 |
+
<googleaddressvalidate_ajax_index>
|
15 |
+
<block type="googleaddressvalidate/ajaxblock" name="root" template="path/template.phtml" />
|
16 |
+
</googleaddressvalidate_ajax_index>
|
17 |
|
18 |
<checkout_onepage_success>
|
19 |
<reference name="head">
|
20 |
+
<block type="page/html" name="craftyclicks_postcheck" template="craftyclicks/googleaddressvalidate/post_checkout.phtml"/>
|
21 |
</reference>
|
22 |
</checkout_onepage_success>
|
23 |
</layout>
|
app/design/frontend/base/default/template/craftyclicks/googleaddressvalidate/post_checkout.phtml
ADDED
@@ -0,0 +1,347 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
|
3 |
+
$order = Mage::getSingleton('sales/order')->loadByIncrementId($orderId);
|
4 |
+
|
5 |
+
$shippingAddress = Mage::getModel('sales/order_address')->load($order->shipping_address_id);
|
6 |
+
|
7 |
+
$confG = Mage::getStoreConfig('googleaddressvalidate/general');
|
8 |
+
$confC = Mage::getStoreConfig('clicktoaddress/general');
|
9 |
+
$confO = Mage::getStoreConfig('general/craftyclicks');
|
10 |
+
|
11 |
+
// if the new config path of cc isn't set, try to get the cc plugin vars from the old cfg.
|
12 |
+
if(!isset($confC['active']) && isset($confO['active'])){
|
13 |
+
$confC = $confO;
|
14 |
+
}
|
15 |
+
|
16 |
+
if($confG['active'] && !($shippingAddress->country_id == 'GB' && 1 == $confC['active']) ):
|
17 |
+
echo '<link rel="stylesheet" type="text/css" href="'.$this->getSkinUrl('css/craftyclicks/googleaddressvalidate/validate.css').'">'; ?>
|
18 |
+
|
19 |
+
<div style="display: none;" id="hidden-correction">
|
20 |
+
<div>
|
21 |
+
<h1>
|
22 |
+
<?php echo $confG['title']; ?>
|
23 |
+
</h1>
|
24 |
+
<div>
|
25 |
+
<?php echo $confG['description_1']; ?>
|
26 |
+
</br>
|
27 |
+
<?php echo $confG['description_2']; ?>
|
28 |
+
</div>
|
29 |
+
|
30 |
+
<div id="crafty-correct">
|
31 |
+
<span class="correct-title">Suggestions:</span>
|
32 |
+
<ul>
|
33 |
+
<li class="manual">
|
34 |
+
<input type="radio" name="option" checked>
|
35 |
+
<span>Manual Correction:</span></br>
|
36 |
+
<div class="field">
|
37 |
+
<label for="address">Address:</label>
|
38 |
+
<div class="input-box">
|
39 |
+
<input type="text" class="crafty-input" id="address"/>
|
40 |
+
</div>
|
41 |
+
</div>
|
42 |
+
<div class="field">
|
43 |
+
<label for="town">Town:</label>
|
44 |
+
<div class="input-box">
|
45 |
+
<input type="text" class="crafty-input" id="town"/>
|
46 |
+
</div>
|
47 |
+
</div>
|
48 |
+
<div class="field"><label for="postcode">Postcode:</label>
|
49 |
+
<div class="input-box">
|
50 |
+
<input type="text" class="crafty-input" id="postcode"/>
|
51 |
+
</div>
|
52 |
+
</div>
|
53 |
+
<div class="field">
|
54 |
+
<label for="region">Region:</label>
|
55 |
+
<div class="input-box">
|
56 |
+
<input type="text" class="crafty-input" id="region"/>
|
57 |
+
<select id="region_id" name="region_id" class="crafty-input">
|
58 |
+
<?php
|
59 |
+
if(!$confG['region_dropdown']){
|
60 |
+
$states = Mage::getModel('directory/country')->load($shippingAddress->country_id)->getRegions()->toOptionArray();
|
61 |
+
foreach($states as $region)
|
62 |
+
{
|
63 |
+
echo "<option value=$region[value]>".$region['title'] . "</option>";
|
64 |
+
}
|
65 |
+
}
|
66 |
+
?>
|
67 |
+
</select>
|
68 |
+
</div>
|
69 |
+
</div>
|
70 |
+
</li>
|
71 |
+
</ul>
|
72 |
+
</div>
|
73 |
+
|
74 |
+
<button class="button" id="button-crafty-modify">Update</button>
|
75 |
+
|
76 |
+
<div id="crafty-maps-holder"></div>
|
77 |
+
|
78 |
+
</div>
|
79 |
+
</div>
|
80 |
+
<script src="//maps.google.com/maps/api/js?sensor=false"></script>
|
81 |
+
<script type="text/javascript">
|
82 |
+
|
83 |
+
<?php
|
84 |
+
if($confG['gmaps']):
|
85 |
+
?>
|
86 |
+
function initialize_gmaps(x,y) {
|
87 |
+
var map_canvas = document.getElementById('crafty-maps-holder');
|
88 |
+
var map_options = {
|
89 |
+
center: new google.maps.LatLng(x,y),
|
90 |
+
zoom: 16,
|
91 |
+
mapTypeId: google.maps.MapTypeId.ROADMAP
|
92 |
+
}
|
93 |
+
var map = new google.maps.Map(map_canvas, map_options);
|
94 |
+
}
|
95 |
+
<?php
|
96 |
+
endif;
|
97 |
+
|
98 |
+
echo "var shipping = '" . json_encode ($shippingAddress->_data) . "'.evalJSON();";
|
99 |
+
|
100 |
+
?>
|
101 |
+
|
102 |
+
function check_match(infoHolder,original){
|
103 |
+
var flag = true;
|
104 |
+
|
105 |
+
if(typeof infoHolder.town !== "undefined" && original.town.toLowerCase() != infoHolder.town.toLowerCase())
|
106 |
+
flag = false;
|
107 |
+
if(typeof infoHolder.postal_code !== "undefined" && original.postal_code.toLowerCase() != infoHolder.postal_code.toLowerCase())
|
108 |
+
flag = false;
|
109 |
+
if(typeof infoHolder.address !== "undefined" && original_address.toLowerCase().indexOf(infoHolder.combined_street.toLowerCase()) == -1)
|
110 |
+
flag = false;
|
111 |
+
|
112 |
+
if(typeof infoHolder.country !== "undefined" && original.country.toLowerCase() != infoHolder.country.short_name.toLowerCase())
|
113 |
+
flag = false;
|
114 |
+
|
115 |
+
return flag;
|
116 |
+
}
|
117 |
+
|
118 |
+
document.observe('dom:loaded', function() {
|
119 |
+
<?php
|
120 |
+
$loading_image = $confG['loading_image'];
|
121 |
+
if($loading_image == ''){
|
122 |
+
$loading_image = 'crafty_validate_busy.gif';
|
123 |
+
}
|
124 |
+
$loading_image = $this->getSkinUrl('images/craftyclicks/googleaddressvalidate/'.$loading_image);
|
125 |
+
?>
|
126 |
+
// check if google CDN loaded properly
|
127 |
+
if(typeof google !== "undefined"){
|
128 |
+
|
129 |
+
var html = '<div class="buttons-set" id="correct_box"><img style="margin: auto;" src="<?php echo $loading_image; ?>"/></div>';
|
130 |
+
|
131 |
+
$$('.buttons-set')[0].insert({before :html});
|
132 |
+
|
133 |
+
|
134 |
+
var address = shipping.street+" "+shipping.postcode+" "+shipping.city+" "+shipping.country_id;
|
135 |
+
|
136 |
+
var geocoder = new google.maps.Geocoder();
|
137 |
+
|
138 |
+
var original = new Object();
|
139 |
+
|
140 |
+
original.street = shipping.street.toLowerCase();
|
141 |
+
original.postalcode = shipping.postcode.toLowerCase();
|
142 |
+
original.city = shipping.city.toLowerCase();
|
143 |
+
|
144 |
+
|
145 |
+
var suggestions = new Array();
|
146 |
+
var data = new Array();
|
147 |
+
|
148 |
+
if (geocoder) {
|
149 |
+
geocoder.geocode({ 'address': address }, function (results, status) {
|
150 |
+
var doCheck = false;
|
151 |
+
//if gmaps fails to locate, then we have some super bogus address.
|
152 |
+
if (status == google.maps.GeocoderStatus.OK) {
|
153 |
+
//parse gmaps data into some more useable format.
|
154 |
+
for(var i = 0; i< results.length; i++ ){
|
155 |
+
data.push(getDataFromMaps(results[i]));
|
156 |
+
}
|
157 |
+
|
158 |
+
//first hit on gmaps is the best find; check if it's premise level.
|
159 |
+
if(typeof data[0].country !== "undefined" && typeof data[0].locality !== "undefined" && typeof data[0].postal_code !== "undefined" && typeof data[0].route !== "undefined" && typeof data[0].street_number !== "undefined"){
|
160 |
+
|
161 |
+
var mapsaddress = new Object();
|
162 |
+
|
163 |
+
//figure out the correct order of housenumber / street.
|
164 |
+
if(data[0].formatted.indexOf(data[0].route) > data[0].formatted.indexOf(data[0].street_number))
|
165 |
+
mapsaddress.street = data[0].street_number.long_name.toLowerCase() + " " + data[0].route.long_name.toLowerCase();
|
166 |
+
else
|
167 |
+
mapsaddress.street = data[0].route.long_name.toLowerCase() + " " + data[0].street_number.long_name.toLowerCase();
|
168 |
+
|
169 |
+
mapsaddress.postalcode = data[0].postal_code.long_name.toLowerCase();
|
170 |
+
mapsaddress.city = data[0].locality.long_name.toLowerCase();
|
171 |
+
|
172 |
+
var old_country_id = shipping.country_id.toLowerCase();
|
173 |
+
|
174 |
+
if(old_country_id == data[0].country.long_name.toLowerCase() || old_country_id == data[0].country.short_name.toLowerCase()){
|
175 |
+
//if countries match AND premise level do not match:
|
176 |
+
if(JSON.stringify(mapsaddress) != JSON.stringify(original)){
|
177 |
+
doCheck = true;
|
178 |
+
}
|
179 |
+
else {
|
180 |
+
//everything matches, remove the validation div. (valid address)
|
181 |
+
$('correct_box').remove();
|
182 |
+
}
|
183 |
+
} else {
|
184 |
+
doCheck = true;
|
185 |
+
}
|
186 |
+
|
187 |
+
} else {
|
188 |
+
doCheck = true;
|
189 |
+
//not premise level
|
190 |
+
}
|
191 |
+
|
192 |
+
}
|
193 |
+
else {
|
194 |
+
//super bogus data
|
195 |
+
doCheck = true;
|
196 |
+
}
|
197 |
+
|
198 |
+
if(doCheck){
|
199 |
+
|
200 |
+
$('correct_box').update($('hidden-correction').innerHTML);
|
201 |
+
$('hidden-correction').remove();
|
202 |
+
|
203 |
+
initialize_gmaps(results[0].geometry.location.lat(), results[0].geometry.location.lng());
|
204 |
+
|
205 |
+
$('address').value = shipping.street;
|
206 |
+
$('town').value = shipping.city;
|
207 |
+
$('postcode').value = shipping.postcode;
|
208 |
+
var country = shipping.country_id;
|
209 |
+
if($('region_id').childElements('option').length){
|
210 |
+
$('region').hide();
|
211 |
+
|
212 |
+
var options = $$('select#region_id option');
|
213 |
+
var len = options.length;
|
214 |
+
for (var i = 0; i < len; i++) {
|
215 |
+
if(options[i].value == shipping.region_id){
|
216 |
+
options[i].selected = true;
|
217 |
+
}
|
218 |
+
}
|
219 |
+
//$('region_id')[shipping.region_id].selected = true;
|
220 |
+
} else {
|
221 |
+
$('region_id').hide();
|
222 |
+
$('region').value = shipping.region;
|
223 |
+
}
|
224 |
+
|
225 |
+
data.forEach(function(element){
|
226 |
+
// if the data provided is premise level
|
227 |
+
if(typeof element.route !== "undefined" && typeof element.street_number !== "undefined"){
|
228 |
+
var address = '';
|
229 |
+
|
230 |
+
var region = '';
|
231 |
+
if(typeof element.administrative_area_level_1 !== "undefined"){
|
232 |
+
region = element.administrative_area_level_1.long_name;
|
233 |
+
}
|
234 |
+
|
235 |
+
var postal_code = '';
|
236 |
+
if(typeof element.postal_code !== "undefined"){
|
237 |
+
postal_code = element.postal_code.long_name;
|
238 |
+
}
|
239 |
+
|
240 |
+
var locality = '';
|
241 |
+
if(typeof element.locality !== "undefined"){
|
242 |
+
locality = element.locality.long_name;
|
243 |
+
}
|
244 |
+
|
245 |
+
var route = '';
|
246 |
+
if(typeof element.route !== "undefined"){
|
247 |
+
route = element.route.long_name;
|
248 |
+
}
|
249 |
+
|
250 |
+
var street_number = '';
|
251 |
+
if(typeof element.street_number !== "undefined"){
|
252 |
+
street_number = element.street_number.long_name;
|
253 |
+
}
|
254 |
+
if(element.formatted.indexOf(route) > element.formatted.indexOf(street_number))
|
255 |
+
address = street_number + " " + route;
|
256 |
+
else
|
257 |
+
address = route + " " + street_number;
|
258 |
+
|
259 |
+
|
260 |
+
var combined_address = address;
|
261 |
+
if(combined_address != '' && locality != ''){
|
262 |
+
combined_address += ', '+locality;
|
263 |
+
}
|
264 |
+
if(combined_address != '' && postal_code != ''){
|
265 |
+
combined_address += ', '+postal_code;
|
266 |
+
}
|
267 |
+
if(combined_address != '' && region != ''){
|
268 |
+
combined_address += ', '+region;
|
269 |
+
}
|
270 |
+
|
271 |
+
var html = '<li data-region="'+region+'" data-postcode="'+postal_code+'" data-town="'+locality+'" data-street="'+ address +'"><input type="radio" class="" name="option"><span>' + combined_address +'</span></li>';
|
272 |
+
$('crafty-correct').down('ul').insert({top : html});
|
273 |
+
}
|
274 |
+
});
|
275 |
+
//if we click on any suggestion, disable manual input
|
276 |
+
$$('#crafty-correct li:not(.manual) input').each(function(elem){
|
277 |
+
elem.observe('click',function(){
|
278 |
+
$$('.crafty-input').each(function(elem){
|
279 |
+
elem.disable();
|
280 |
+
});
|
281 |
+
});
|
282 |
+
});
|
283 |
+
//if we click on manual correct, enable manual input
|
284 |
+
$$('#crafty-correct li.manual input')[0].observe('click',function(){
|
285 |
+
$$('.crafty-input').each(function(elem){
|
286 |
+
elem.enable();
|
287 |
+
});
|
288 |
+
});
|
289 |
+
//when we press the update button
|
290 |
+
$('button-crafty-modify').observe('click',function(){
|
291 |
+
//check if a suggestion is selected
|
292 |
+
var elem = $$('#crafty-correct li:not(.manual) input[type=radio]:checked');
|
293 |
+
if(elem.length == 1){
|
294 |
+
//gather all data and copy it to the form.
|
295 |
+
var li = elem[0].up('li');
|
296 |
+
$('address').value = li.readAttribute('data-street');
|
297 |
+
$('town').value = li.readAttribute('data-town');
|
298 |
+
$('postcode').value = li.readAttribute('data-postcode');
|
299 |
+
$('region').value = li.readAttribute('data-region');
|
300 |
+
} else {
|
301 |
+
//if it's manual & region dropdown is provided, copy the selected region value to the region form element.
|
302 |
+
if($('region_id').childElements('option').length){
|
303 |
+
$('region').value = $('region_id').options[$('region_id').selectedIndex].innerHTML;
|
304 |
+
}
|
305 |
+
}
|
306 |
+
// pass all form values to an ajax request & update.
|
307 |
+
new Ajax.Request('<?php echo Mage::getUrl('googleaddressvalidate/ajax/update');?>',
|
308 |
+
{
|
309 |
+
method:'get',
|
310 |
+
parameters: {
|
311 |
+
street: $('address').getValue(),
|
312 |
+
city: $('town').getValue(),
|
313 |
+
postcode: $('postcode').getValue(),
|
314 |
+
region: $('region').getValue()
|
315 |
+
},
|
316 |
+
onSuccess: function(transport){
|
317 |
+
$('correct_box').update('<?php echo addslashes($confG['finish_text']); ?>');
|
318 |
+
}
|
319 |
+
});
|
320 |
+
});
|
321 |
+
|
322 |
+
}
|
323 |
+
});
|
324 |
+
}
|
325 |
+
}
|
326 |
+
|
327 |
+
} );
|
328 |
+
|
329 |
+
function getDataFromMaps(element){
|
330 |
+
var output = new Array();
|
331 |
+
element.address_components.forEach(function(inner_element, index2, array2){
|
332 |
+
output[inner_element.types[0]] = new Object();
|
333 |
+
output[inner_element.types[0]].long_name = inner_element.long_name;
|
334 |
+
output[inner_element.types[0]].short_name = inner_element.short_name;
|
335 |
+
});
|
336 |
+
var result = new Object();
|
337 |
+
result = output;
|
338 |
+
result.formatted = element.formatted_address;
|
339 |
+
return result;
|
340 |
+
|
341 |
+
}
|
342 |
+
|
343 |
+
</script>
|
344 |
+
|
345 |
+
<?php
|
346 |
+
endif;
|
347 |
+
?>
|
app/design/frontend/base/default/template/craftyclicksvalidate/post_checkout.phtml
DELETED
@@ -1,343 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
$orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
|
3 |
-
$order = Mage::getSingleton('sales/order')->loadByIncrementId($orderId);
|
4 |
-
|
5 |
-
$shippingAddress = Mage::getModel('sales/order_address')->load($order->shipping_address_id);
|
6 |
-
|
7 |
-
$conf = Mage::getStoreConfig('general');
|
8 |
-
|
9 |
-
if($conf['craftyclicksvalidate']['active'] && !($shippingAddress->country_id == 'GB' && 1 == $conf['craftyclicks']['active']) ){
|
10 |
-
?>
|
11 |
-
|
12 |
-
<?php echo '<link rel="stylesheet" type="text/css" href="'.$this->getSkinUrl('css/craftyclicksvalidate/validate.css').'">'; ?>
|
13 |
-
|
14 |
-
<div style="display: none;" id="hidden-correction">
|
15 |
-
<div>
|
16 |
-
<h1>
|
17 |
-
<?php echo $conf['craftyclicksvalidate']['title']; ?>
|
18 |
-
</h1>
|
19 |
-
<div>
|
20 |
-
<?php echo $conf['craftyclicksvalidate']['description_1']; ?>
|
21 |
-
</br>
|
22 |
-
<?php echo $conf['craftyclicksvalidate']['description_2']; ?>
|
23 |
-
</div>
|
24 |
-
|
25 |
-
<div id="crafty-correct">
|
26 |
-
<span class="correct-title">Suggestions:</span>
|
27 |
-
<ul>
|
28 |
-
<li class="manual">
|
29 |
-
<input type="radio" name="option" checked>
|
30 |
-
<span>Manual Correction:</span></br>
|
31 |
-
<div class="field">
|
32 |
-
<label for="address">Address:</label>
|
33 |
-
<div class="input-box">
|
34 |
-
<input type="text" class="crafty-input" id="address"/>
|
35 |
-
</div>
|
36 |
-
</div>
|
37 |
-
<div class="field">
|
38 |
-
<label for="town">Town:</label>
|
39 |
-
<div class="input-box">
|
40 |
-
<input type="text" class="crafty-input" id="town"/>
|
41 |
-
</div>
|
42 |
-
</div>
|
43 |
-
<div class="field"><label for="postcode">Postcode:</label>
|
44 |
-
<div class="input-box">
|
45 |
-
<input type="text" class="crafty-input" id="postcode"/>
|
46 |
-
</div>
|
47 |
-
</div>
|
48 |
-
<div class="field">
|
49 |
-
<label for="region">Region:</label>
|
50 |
-
<div class="input-box">
|
51 |
-
<input type="text" class="crafty-input" id="region"/>
|
52 |
-
<select id="region_id" name="region_id" class="crafty-input">
|
53 |
-
<?php
|
54 |
-
if(!$conf['craftyclicksvalidate']['region_dropdown']){
|
55 |
-
$states = Mage::getModel('directory/country')->load($shippingAddress->country_id)->getRegions()->toOptionArray();
|
56 |
-
foreach($states as $region)
|
57 |
-
{
|
58 |
-
echo "<option value=$region[value]>".$region['title'] . "</option>";
|
59 |
-
}
|
60 |
-
}
|
61 |
-
?>
|
62 |
-
</select>
|
63 |
-
</div>
|
64 |
-
</div>
|
65 |
-
</li>
|
66 |
-
</ul>
|
67 |
-
</div>
|
68 |
-
|
69 |
-
<button class="button" id="button-crafty-modify">Update</button>
|
70 |
-
|
71 |
-
<div id="crafty-maps-holder"></div>
|
72 |
-
|
73 |
-
</div>
|
74 |
-
</div>
|
75 |
-
<script src="//maps.google.com/maps/api/js?sensor=false"></script>
|
76 |
-
<script type="text/javascript">
|
77 |
-
|
78 |
-
<?php
|
79 |
-
if($conf['craftyclicksvalidate']['gmaps']){
|
80 |
-
?>
|
81 |
-
function initialize_gmaps(x,y) {
|
82 |
-
var map_canvas = document.getElementById('crafty-maps-holder');
|
83 |
-
var map_options = {
|
84 |
-
center: new google.maps.LatLng(x,y),
|
85 |
-
zoom: 16,
|
86 |
-
mapTypeId: google.maps.MapTypeId.ROADMAP
|
87 |
-
}
|
88 |
-
var map = new google.maps.Map(map_canvas, map_options);
|
89 |
-
}
|
90 |
-
|
91 |
-
<?php
|
92 |
-
}
|
93 |
-
|
94 |
-
echo "var shipping = '" . json_encode ($shippingAddress->_data) . "'.evalJSON();";
|
95 |
-
|
96 |
-
?>
|
97 |
-
|
98 |
-
function check_match(infoHolder,original){
|
99 |
-
var flag = true;
|
100 |
-
|
101 |
-
if(typeof infoHolder.town !== "undefined" && original.town.toLowerCase() != infoHolder.town.toLowerCase())
|
102 |
-
flag = false;
|
103 |
-
if(typeof infoHolder.postal_code !== "undefined" && original.postal_code.toLowerCase() != infoHolder.postal_code.toLowerCase())
|
104 |
-
flag = false;
|
105 |
-
if(typeof infoHolder.address !== "undefined" && original_address.toLowerCase().indexOf(infoHolder.combined_street.toLowerCase()) == -1)
|
106 |
-
flag = false;
|
107 |
-
|
108 |
-
if(typeof infoHolder.country !== "undefined" && original.country.toLowerCase() != infoHolder.country.short_name.toLowerCase())
|
109 |
-
flag = false;
|
110 |
-
|
111 |
-
return flag;
|
112 |
-
}
|
113 |
-
|
114 |
-
document.observe('dom:loaded', function() {
|
115 |
-
<?php
|
116 |
-
$loading_image = $conf['craftyclicksvalidate']['loading_image'];
|
117 |
-
if($loading_image == ''){
|
118 |
-
$loading_image = 'crafty_validate_busy.gif';
|
119 |
-
}
|
120 |
-
$loading_image = $this->getSkinUrl('images/craftyclicksvalidate/'.$loading_image);
|
121 |
-
?>
|
122 |
-
// check if google CDN loaded properly
|
123 |
-
if(typeof google !== "undefined"){
|
124 |
-
|
125 |
-
var html = '<div class="buttons-set" id="correct_box"><img style="margin: auto;" src="<?php echo $loading_image; ?>"/></div>';
|
126 |
-
|
127 |
-
$$('.buttons-set')[0].insert({before :html});
|
128 |
-
|
129 |
-
|
130 |
-
var address = shipping.street+" "+shipping.postcode+" "+shipping.city+" "+shipping.country_id;
|
131 |
-
|
132 |
-
var geocoder = new google.maps.Geocoder();
|
133 |
-
|
134 |
-
var original = new Object();
|
135 |
-
|
136 |
-
original.street = shipping.street.toLowerCase();
|
137 |
-
original.postalcode = shipping.postcode.toLowerCase();
|
138 |
-
original.city = shipping.city.toLowerCase();
|
139 |
-
|
140 |
-
|
141 |
-
var suggestions = new Array();
|
142 |
-
var data = new Array();
|
143 |
-
|
144 |
-
if (geocoder) {
|
145 |
-
geocoder.geocode({ 'address': address }, function (results, status) {
|
146 |
-
var doCheck = false;
|
147 |
-
//if gmaps fails to locate, then we have some super bogus address.
|
148 |
-
if (status == google.maps.GeocoderStatus.OK) {
|
149 |
-
//parse gmaps data into some more useable format.
|
150 |
-
for(var i = 0; i< results.length; i++ ){
|
151 |
-
data.push(getDataFromMaps(results[i]));
|
152 |
-
}
|
153 |
-
|
154 |
-
//first hit on gmaps is the best find; check if it's premise level.
|
155 |
-
if(typeof data[0].country !== "undefined" && typeof data[0].locality !== "undefined" && typeof data[0].postal_code !== "undefined" && typeof data[0].route !== "undefined" && typeof data[0].street_number !== "undefined"){
|
156 |
-
|
157 |
-
var mapsaddress = new Object();
|
158 |
-
|
159 |
-
//figure out the correct order of housenumber / street.
|
160 |
-
if(data[0].formatted.indexOf(data[0].route) > data[0].formatted.indexOf(data[0].street_number))
|
161 |
-
mapsaddress.street = data[0].street_number.long_name.toLowerCase() + " " + data[0].route.long_name.toLowerCase();
|
162 |
-
else
|
163 |
-
mapsaddress.street = data[0].route.long_name.toLowerCase() + " " + data[0].street_number.long_name.toLowerCase();
|
164 |
-
|
165 |
-
mapsaddress.postalcode = data[0].postal_code.long_name.toLowerCase();
|
166 |
-
mapsaddress.city = data[0].locality.long_name.toLowerCase();
|
167 |
-
|
168 |
-
var old_country_id = shipping.country_id.toLowerCase();
|
169 |
-
|
170 |
-
if(old_country_id == data[0].country.long_name.toLowerCase() || old_country_id == data[0].country.short_name.toLowerCase()){
|
171 |
-
//if countries match AND premise level do not match:
|
172 |
-
if(JSON.stringify(mapsaddress) != JSON.stringify(original)){
|
173 |
-
doCheck = true;
|
174 |
-
}
|
175 |
-
else {
|
176 |
-
//everything matches, remove the validation div. (valid address)
|
177 |
-
$('correct_box').remove();
|
178 |
-
}
|
179 |
-
} else {
|
180 |
-
doCheck = true;
|
181 |
-
}
|
182 |
-
|
183 |
-
} else {
|
184 |
-
doCheck = true;
|
185 |
-
//not premise level
|
186 |
-
}
|
187 |
-
|
188 |
-
}
|
189 |
-
else {
|
190 |
-
//super bogus data
|
191 |
-
doCheck = true;
|
192 |
-
}
|
193 |
-
|
194 |
-
if(doCheck){
|
195 |
-
|
196 |
-
$('correct_box').update($('hidden-correction').innerHTML);
|
197 |
-
$('hidden-correction').remove();
|
198 |
-
|
199 |
-
initialize_gmaps(results[0].geometry.location.lat(), results[0].geometry.location.lng());
|
200 |
-
|
201 |
-
$('address').value = shipping.street;
|
202 |
-
$('town').value = shipping.city;
|
203 |
-
$('postcode').value = shipping.postcode;
|
204 |
-
var country = shipping.country_id;
|
205 |
-
if($('region_id').childElements('option').length){
|
206 |
-
$('region').hide();
|
207 |
-
|
208 |
-
var options = $$('select#region_id option');
|
209 |
-
var len = options.length;
|
210 |
-
for (var i = 0; i < len; i++) {
|
211 |
-
if(options[i].value == shipping.region_id){
|
212 |
-
options[i].selected = true;
|
213 |
-
}
|
214 |
-
}
|
215 |
-
//$('region_id')[shipping.region_id].selected = true;
|
216 |
-
} else {
|
217 |
-
$('region_id').hide();
|
218 |
-
$('region').value = shipping.region;
|
219 |
-
}
|
220 |
-
|
221 |
-
data.forEach(function(element){
|
222 |
-
// if the data provided is premise level
|
223 |
-
if(typeof element.route !== "undefined" && typeof element.street_number !== "undefined"){
|
224 |
-
var address = '';
|
225 |
-
|
226 |
-
var region = '';
|
227 |
-
if(typeof element.administrative_area_level_1 !== "undefined"){
|
228 |
-
region = element.administrative_area_level_1.long_name;
|
229 |
-
}
|
230 |
-
|
231 |
-
var postal_code = '';
|
232 |
-
if(typeof element.postal_code !== "undefined"){
|
233 |
-
postal_code = element.postal_code.long_name;
|
234 |
-
}
|
235 |
-
|
236 |
-
var locality = '';
|
237 |
-
if(typeof element.locality !== "undefined"){
|
238 |
-
locality = element.locality.long_name;
|
239 |
-
}
|
240 |
-
|
241 |
-
var route = '';
|
242 |
-
if(typeof element.route !== "undefined"){
|
243 |
-
route = element.route.long_name;
|
244 |
-
}
|
245 |
-
|
246 |
-
var street_number = '';
|
247 |
-
if(typeof element.street_number !== "undefined"){
|
248 |
-
street_number = element.street_number.long_name;
|
249 |
-
}
|
250 |
-
if(element.formatted.indexOf(route) > element.formatted.indexOf(street_number))
|
251 |
-
address = street_number + " " + route;
|
252 |
-
else
|
253 |
-
address = route + " " + street_number;
|
254 |
-
|
255 |
-
|
256 |
-
var combined_address = address;
|
257 |
-
if(combined_address != '' && locality != ''){
|
258 |
-
combined_address += ', '+locality;
|
259 |
-
}
|
260 |
-
if(combined_address != '' && postal_code != ''){
|
261 |
-
combined_address += ', '+postal_code;
|
262 |
-
}
|
263 |
-
if(combined_address != '' && region != ''){
|
264 |
-
combined_address += ', '+region;
|
265 |
-
}
|
266 |
-
|
267 |
-
var html = '<li data-region="'+region+'" data-postcode="'+postal_code+'" data-town="'+locality+'" data-street="'+ address +'"><input type="radio" class="" name="option"><span>' + combined_address +'</span></li>';
|
268 |
-
$('crafty-correct').down('ul').insert({top : html});
|
269 |
-
}
|
270 |
-
});
|
271 |
-
//if we click on any suggestion, disable manual input
|
272 |
-
$$('#crafty-correct li:not(.manual) input').each(function(elem){
|
273 |
-
elem.observe('click',function(){
|
274 |
-
$$('.crafty-input').each(function(elem){
|
275 |
-
elem.disable();
|
276 |
-
});
|
277 |
-
});
|
278 |
-
});
|
279 |
-
//if we click on manual correct, enable manual input
|
280 |
-
$$('#crafty-correct li.manual input')[0].observe('click',function(){
|
281 |
-
$$('.crafty-input').each(function(elem){
|
282 |
-
elem.enable();
|
283 |
-
});
|
284 |
-
});
|
285 |
-
//when we press the update button
|
286 |
-
$('button-crafty-modify').observe('click',function(){
|
287 |
-
//check if a suggestion is selected
|
288 |
-
var elem = $$('#crafty-correct li:not(.manual) input[type=radio]:checked');
|
289 |
-
if(elem.length == 1){
|
290 |
-
//gather all data and copy it to the form.
|
291 |
-
var li = elem[0].up('li');
|
292 |
-
$('address').value = li.readAttribute('data-street');
|
293 |
-
$('town').value = li.readAttribute('data-town');
|
294 |
-
$('postcode').value = li.readAttribute('data-postcode');
|
295 |
-
$('region').value = li.readAttribute('data-region');
|
296 |
-
} else {
|
297 |
-
//if it's manual & region dropdown is provided, copy the selected region value to the region form element.
|
298 |
-
if($('region_id').childElements('option').length){
|
299 |
-
$('region').value = $('region_id').options[$('region_id').selectedIndex].innerHTML;
|
300 |
-
}
|
301 |
-
}
|
302 |
-
// pass all form values to an ajax request & update.
|
303 |
-
new Ajax.Request('<?php echo Mage::getUrl('craftyclicksvalidate/ajax/update');?>',
|
304 |
-
{
|
305 |
-
method:'get',
|
306 |
-
parameters: {
|
307 |
-
street: $('address').getValue(),
|
308 |
-
city: $('town').getValue(),
|
309 |
-
postcode: $('postcode').getValue(),
|
310 |
-
region: $('region').getValue()
|
311 |
-
},
|
312 |
-
onSuccess: function(transport){
|
313 |
-
$('correct_box').update('<?php echo addslashes($conf['craftyclicksvalidate']['finish_text']); ?>');
|
314 |
-
}
|
315 |
-
});
|
316 |
-
});
|
317 |
-
|
318 |
-
}
|
319 |
-
});
|
320 |
-
}
|
321 |
-
}
|
322 |
-
|
323 |
-
} );
|
324 |
-
|
325 |
-
function getDataFromMaps(element){
|
326 |
-
var output = new Array();
|
327 |
-
element.address_components.forEach(function(inner_element, index2, array2){
|
328 |
-
output[inner_element.types[0]] = new Object();
|
329 |
-
output[inner_element.types[0]].long_name = inner_element.long_name;
|
330 |
-
output[inner_element.types[0]].short_name = inner_element.short_name;
|
331 |
-
});
|
332 |
-
var result = new Object();
|
333 |
-
result = output;
|
334 |
-
result.formatted = element.formatted_address;
|
335 |
-
return result;
|
336 |
-
|
337 |
-
}
|
338 |
-
|
339 |
-
</script>
|
340 |
-
|
341 |
-
<?php
|
342 |
-
}
|
343 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/etc/modules/CraftyClicksValidate.xml
CHANGED
@@ -2,8 +2,9 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<CraftyClicksValidate>
|
5 |
-
<active>
|
6 |
<codePool>local</codePool>
|
|
|
7 |
</CraftyClicksValidate>
|
8 |
</modules>
|
9 |
</config>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<CraftyClicksValidate>
|
5 |
+
<active>false</active>
|
6 |
<codePool>local</codePool>
|
7 |
+
<version>0.1.4</version>
|
8 |
</CraftyClicksValidate>
|
9 |
</modules>
|
10 |
</config>
|
app/etc/modules/Craftyclicks_Googleaddressvalidate.xml
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
|
3 |
+
<config>
|
4 |
+
<modules>
|
5 |
+
<Craftyclicks_Googleaddressvalidate>
|
6 |
+
<active>true</active>
|
7 |
+
<codePool>community</codePool>
|
8 |
+
</Craftyclicks_Googleaddressvalidate>
|
9 |
+
</modules>
|
10 |
+
</config>
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Crafty_Clicks_International_Address_Validation</name>
|
4 |
-
<version>0.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
<channel>community</channel>
|
@@ -11,11 +11,8 @@
|
|
11 |

|
12 |
Upon completing a checkout, the shipping address gets validated, to ensure the existence of the location. In case the address cannot be confirmed, suggestions to fix the address will be shown, with the option to manually check and fix the address.</description>
|
13 |
<notes>Release History
|
14 |
-
v0.
|
15 |
-
*
|
16 |
-
* Small improvements based on community feedback
|
17 |
-
v0.1.5
|
18 |
-
* Code clean up
|
19 |
v0.1.4
|
20 |
* Fix: better handling of region dropdowns
|
21 |
v0.1.3
|
@@ -27,9 +24,9 @@ v0.1.1
|
|
27 |
v0.1.0
|
28 |
* Initial Release</notes>
|
29 |
<authors><author><name>Crafty Clicks</name><user>styloa</user><email>support@craftyclicks.co.uk</email></author></authors>
|
30 |
-
<date>2014-
|
31 |
-
<time>
|
32 |
-
<contents><target name="mage"><dir name="app"><dir name="etc"><dir name="modules"><file name="CraftyClicksValidate.xml" hash="
|
33 |
<compatible/>
|
34 |
<dependencies><required><php><min>4.0.0</min><max>6.0.0</max></php></required></dependencies>
|
35 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Crafty_Clicks_International_Address_Validation</name>
|
4 |
+
<version>0.2.0</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
<channel>community</channel>
|
11 |

|
12 |
Upon completing a checkout, the shipping address gets validated, to ensure the existence of the location. In case the address cannot be confirmed, suggestions to fix the address will be shown, with the option to manually check and fix the address.</description>
|
13 |
<notes>Release History
|
14 |
+
v0.2.0
|
15 |
+
* Major Structural Rework
|
|
|
|
|
|
|
16 |
v0.1.4
|
17 |
* Fix: better handling of region dropdowns
|
18 |
v0.1.3
|
24 |
v0.1.0
|
25 |
* Initial Release</notes>
|
26 |
<authors><author><name>Crafty Clicks</name><user>styloa</user><email>support@craftyclicks.co.uk</email></author></authors>
|
27 |
+
<date>2014-10-22</date>
|
28 |
+
<time>13:04:21</time>
|
29 |
+
<contents><target name="mage"><dir name="app"><dir name="etc"><dir name="modules"><file name="CraftyClicksValidate.xml" hash="7756c3b4282faf7d570b10990b7690d4"/><file name="Craftyclicks_Googleaddressvalidate.xml" hash="98941aa74d74ad1b38e7e115e8fa2054"/></dir></dir><dir name="code"><dir name="community"><dir name="Craftyclicks"><dir name="Googleaddressvalidate"><dir><dir name="Helper"><file name="Data.php" hash="88b3d1efbb6062cca7c6e1107ef56417"/></dir><dir name="controllers"><file name="AjaxController.php" hash="d104bd4b0d88e89251aa8b58a5cbee6e"/></dir><dir name="data"><dir name="craftyclicks_googleaddressvalidate_setup"><file name="data-upgrade-0.1.6-0.2.0.php" hash="a8210b72c41b6087d62ea130936e09ef"/></dir></dir><dir name="etc"><file name="config.xml" hash="a7fa36f19646ff4117013e807e19b1d4"/><file name="system.xml" hash="7bbe0380ac35e132cf32ff3dbf5ff031"/></dir></dir></dir></dir></dir></dir><dir name="design"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="craftyclicks_googleaddressvalidate.xml" hash="b785571ac8a14fcde43cb76dce15908f"/></dir><dir name="template"><dir name="craftyclicks"><dir name="googleaddressvalidate"><file name="post_checkout.phtml" hash="68a9c8634c32545b3f3ba180bcf7294d"/></dir></dir></dir></dir></dir></dir></dir></dir><dir name="skin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="craftyclicks"><dir name="googleaddressvalidate"><file name="validate.css" hash="353e6e8267ce0a7fccad15bc1d1418cd"/><file name="validate_old.css" hash="3a4dd9986bdf93462afb0c6a20ac838e"/></dir></dir></dir><dir name="images"><dir name="craftyclicks"><dir name="googleaddressvalidate"><file name="crafty_validate_busy.gif" hash="7660c91e294e91f80219d3c8f6512dca"/></dir></dir></dir></dir></dir></dir></dir></target></contents>
|
30 |
<compatible/>
|
31 |
<dependencies><required><php><min>4.0.0</min><max>6.0.0</max></php></required></dependencies>
|
32 |
</package>
|
skin/frontend/base/default/css/{craftyclicksvalidate → craftyclicks/googleaddressvalidate}/validate.css
RENAMED
File without changes
|
skin/frontend/base/default/css/{craftyclicksvalidate → craftyclicks/googleaddressvalidate}/validate_old.css
RENAMED
File without changes
|
skin/frontend/base/default/images/{craftyclicksvalidate → craftyclicks/googleaddressvalidate}/crafty_validate_busy.gif
RENAMED
File without changes
|