Version Notes
test notes
Download this release
Release Info
Developer | Extensions Store |
Extension | Addressvalidator |
Version | 1.4.0 |
Comparing to | |
See all releases |
Code changes from version 1.3.0 to 1.4.0
- app/code/community/Aydus/Addressvalidator/Helper/Data.php +30 -1
- app/code/community/Aydus/Addressvalidator/Model/Address.php +23 -0
- app/code/community/Aydus/Addressvalidator/Model/Observer.php +74 -12
- app/code/community/Aydus/Addressvalidator/Model/Resource/Address.php +21 -0
- app/code/community/Aydus/Addressvalidator/Model/Resource/Address/Collection.php +21 -0
- app/code/community/Aydus/Addressvalidator/etc/config.xml +20 -1
- app/code/community/Aydus/Addressvalidator/sql/aydus_addressvalidator_setup/upgrade-1.3.0-1.4.0.php +22 -0
- app/etc/modules/Aydus_Addressvalidator.xml +18 -0
- package.xml +10 -10
- skin/frontend/base/default/images/aydus/addressvalidator/LOGO_L.gif +0 -0
- skin/frontend/base/default/images/aydus/addressvalidator/LOGO_S.gif +0 -0
- skin/frontend/base/default/js/aydus/addressvalidator.js +327 -0
- skin/frontend/base/default/js/aydus/addressvalidator/address.js +110 -0
app/code/community/Aydus/Addressvalidator/Helper/Data.php
CHANGED
@@ -235,7 +235,21 @@ class Aydus_Addressvalidator_Helper_Data extends Mage_Core_Helper_Abstract {
|
|
235 |
|
236 |
$customerAddress = Mage::getModel('customer/address')->load($customerAddressId);
|
237 |
$customerAddress->addData($data);
|
238 |
-
$customerAddress->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
239 |
}
|
240 |
|
241 |
if ($address->getAddressType() == 'billing'){
|
@@ -255,7 +269,22 @@ class Aydus_Addressvalidator_Helper_Data extends Mage_Core_Helper_Abstract {
|
|
255 |
|
256 |
$customerShippingAddress = Mage::getModel('customer/address')->load($customerAddressId);
|
257 |
$customerShippingAddress->addData($data);
|
|
|
258 |
$customerShippingAddress->save();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
259 |
}
|
260 |
|
261 |
}
|
235 |
|
236 |
$customerAddress = Mage::getModel('customer/address')->load($customerAddressId);
|
237 |
$customerAddress->addData($data);
|
238 |
+
$customerAddress->setPopulated(1);
|
239 |
+
$customerAddress->save();
|
240 |
+
|
241 |
+
$datetime = date('Y-m-d H:i:s');
|
242 |
+
|
243 |
+
$validatedAddress = Mage::getModel('aydus_addressvalidator/address');
|
244 |
+
$validatedAddress->load($customerAddress->getId(), 'address_id');
|
245 |
+
$validatedAddress->setAddressId($customerAddress->getId());
|
246 |
+
$validatedAddress->setAddressType($customerAddress->getAddressType());
|
247 |
+
$validatedAddress->setValidated(1);
|
248 |
+
if (!$validatedAddress->getId()){
|
249 |
+
$validatedAddress->setDateCreated($datetime);
|
250 |
+
}
|
251 |
+
$validatedAddress->setDateUpdated($datetime);
|
252 |
+
$validatedAddress->save();
|
253 |
}
|
254 |
|
255 |
if ($address->getAddressType() == 'billing'){
|
269 |
|
270 |
$customerShippingAddress = Mage::getModel('customer/address')->load($customerAddressId);
|
271 |
$customerShippingAddress->addData($data);
|
272 |
+
$customerShippingAddress->setPopulated(1);
|
273 |
$customerShippingAddress->save();
|
274 |
+
|
275 |
+
$datetime = date('Y-m-d H:i:s');
|
276 |
+
|
277 |
+
$validatedShippingAddress = Mage::getModel('aydus_addressvalidator/address');
|
278 |
+
$validatedShippingAddress->load($customerShippingAddress->getId(), 'address_id');
|
279 |
+
$validatedShippingAddress->setAddressId($customerShippingAddress->getId());
|
280 |
+
$validatedShippingAddress->setAddressType($customerShippingAddress->getAddressType());
|
281 |
+
$validatedShippingAddress->setValidated(1);
|
282 |
+
if (!$validatedShippingAddress->getId()){
|
283 |
+
$validatedShippingAddress->setDateCreated($datetime);
|
284 |
+
}
|
285 |
+
$validatedShippingAddress->setDateUpdated($datetime);
|
286 |
+
$validatedShippingAddress->save();
|
287 |
+
|
288 |
}
|
289 |
|
290 |
}
|
app/code/community/Aydus/Addressvalidator/Model/Address.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Address model
|
5 |
+
*
|
6 |
+
* @category Aydus
|
7 |
+
* @package Aydus_Addressvalidator
|
8 |
+
* @author Aydus <davidt@aydus.com>
|
9 |
+
*/
|
10 |
+
|
11 |
+
class Aydus_Addressvalidator_Model_Address extends Mage_Core_Model_Abstract
|
12 |
+
{
|
13 |
+
/**
|
14 |
+
* Initialize resource model
|
15 |
+
*/
|
16 |
+
protected function _construct()
|
17 |
+
{
|
18 |
+
parent::_construct();
|
19 |
+
|
20 |
+
$this->_init('aydus_addressvalidator/address');
|
21 |
+
}
|
22 |
+
|
23 |
+
}
|
app/code/community/Aydus/Addressvalidator/Model/Observer.php
CHANGED
@@ -14,14 +14,26 @@ class Aydus_Addressvalidator_Model_Observer extends Mage_Core_Model_Abstract {
|
|
14 |
* Validate address using configured service, rewrite response if suggestions available
|
15 |
*
|
16 |
* @param Varien_Event_Observer $observer
|
|
|
17 |
*/
|
18 |
public function validateAddress($observer) {
|
|
|
19 |
$request = Mage::app()->getRequest();
|
20 |
//skip validation if already validated
|
21 |
$addressValidated = $request->getParam('address_validated');
|
22 |
if ($addressValidated) {
|
23 |
-
return $
|
|
|
|
|
|
|
|
|
24 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
$event = $observer->getEvent();
|
27 |
$controller = $event->getControllerAction();
|
@@ -47,15 +59,14 @@ class Aydus_Addressvalidator_Model_Observer extends Mage_Core_Model_Abstract {
|
|
47 |
$validateStore = $helper->validateStore($store);
|
48 |
|
49 |
if ($validateStore) {
|
50 |
-
|
51 |
-
$event = $observer->getEvent();
|
52 |
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
53 |
-
|
54 |
if ($event->getName() == 'controller_action_postdispatch_checkout_onepage_saveBilling') {
|
55 |
-
|
56 |
$address = $quote->getBillingAddress();
|
57 |
} else {
|
58 |
-
|
59 |
$address = $quote->getShippingAddress();
|
60 |
}
|
61 |
|
@@ -76,19 +87,19 @@ class Aydus_Addressvalidator_Model_Observer extends Mage_Core_Model_Abstract {
|
|
76 |
$result = array();
|
77 |
$result['validate'] = true;
|
78 |
$result['error'] = false;
|
79 |
-
|
80 |
if (is_array($returned['data']) && count($returned['data']) > 0) {
|
81 |
|
82 |
$result['data'] = json_encode($returned['data']);
|
83 |
$result['message'] = $helper->getMessaging('matches_available') . $responseCode;
|
84 |
|
|
|
|
|
85 |
$autoPopulate = (int)Mage::getStoreConfig('aydus_addressvalidator/configuration/auto_populate', $storeId);
|
86 |
|
87 |
if ($autoPopulate){
|
88 |
-
|
89 |
-
|
90 |
-
return $observer;
|
91 |
-
}
|
92 |
}
|
93 |
|
94 |
} else {
|
@@ -98,7 +109,20 @@ class Aydus_Addressvalidator_Model_Observer extends Mage_Core_Model_Abstract {
|
|
98 |
$result['message'] = $helper->getMessaging('invalid_address') . $responseCode;
|
99 |
}
|
100 |
|
101 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
|
103 |
$observer->setResult($result);
|
104 |
}
|
@@ -107,4 +131,42 @@ class Aydus_Addressvalidator_Model_Observer extends Mage_Core_Model_Abstract {
|
|
107 |
return $observer;
|
108 |
}
|
109 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
}
|
14 |
* Validate address using configured service, rewrite response if suggestions available
|
15 |
*
|
16 |
* @param Varien_Event_Observer $observer
|
17 |
+
* @return Varien_Event_Observer $observer
|
18 |
*/
|
19 |
public function validateAddress($observer) {
|
20 |
+
|
21 |
$request = Mage::app()->getRequest();
|
22 |
//skip validation if already validated
|
23 |
$addressValidated = $request->getParam('address_validated');
|
24 |
if ($addressValidated) {
|
25 |
+
return $observer;
|
26 |
+
}
|
27 |
+
$addressId = $request->getParam('billing_address_id');
|
28 |
+
if (!$addressId){
|
29 |
+
$addressId = $request->getParam('shipping_address_id');
|
30 |
}
|
31 |
+
$validatedAddress = Mage::getModel('aydus_addressvalidator/address');
|
32 |
+
$validatedAddress->load($addressId, 'address_id');
|
33 |
+
|
34 |
+
if ($validatedAddress->getId() && $validatedAddress->getValidated()){
|
35 |
+
return $observer;
|
36 |
+
}
|
37 |
|
38 |
$event = $observer->getEvent();
|
39 |
$controller = $event->getControllerAction();
|
59 |
$validateStore = $helper->validateStore($store);
|
60 |
|
61 |
if ($validateStore) {
|
62 |
+
|
|
|
63 |
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
64 |
+
|
65 |
if ($event->getName() == 'controller_action_postdispatch_checkout_onepage_saveBilling') {
|
66 |
+
|
67 |
$address = $quote->getBillingAddress();
|
68 |
} else {
|
69 |
+
|
70 |
$address = $quote->getShippingAddress();
|
71 |
}
|
72 |
|
87 |
$result = array();
|
88 |
$result['validate'] = true;
|
89 |
$result['error'] = false;
|
90 |
+
|
91 |
if (is_array($returned['data']) && count($returned['data']) > 0) {
|
92 |
|
93 |
$result['data'] = json_encode($returned['data']);
|
94 |
$result['message'] = $helper->getMessaging('matches_available') . $responseCode;
|
95 |
|
96 |
+
$helper->setAddressData($address, $returned['data'][0]);
|
97 |
+
|
98 |
$autoPopulate = (int)Mage::getStoreConfig('aydus_addressvalidator/configuration/auto_populate', $storeId);
|
99 |
|
100 |
if ($autoPopulate){
|
101 |
+
$observer->setResult($result);
|
102 |
+
return $observer;
|
|
|
|
|
103 |
}
|
104 |
|
105 |
} else {
|
109 |
$result['message'] = $helper->getMessaging('invalid_address') . $responseCode;
|
110 |
}
|
111 |
|
112 |
+
$rates = null;
|
113 |
+
|
114 |
+
if ($address->getAddressType()=='billing'){
|
115 |
+
|
116 |
+
$billing = $request->getParam('billing');
|
117 |
+
|
118 |
+
if ($billing['use_for_shipping']){
|
119 |
+
$rates = $quote->getShippingAddress()->collectShippingRates()->getGroupedAllShippingRates();
|
120 |
+
}
|
121 |
+
}
|
122 |
+
|
123 |
+
if (is_array($rates) && count($rates)>0){
|
124 |
+
$response->setBody(Mage::helper('core')->jsonEncode($result));
|
125 |
+
}
|
126 |
|
127 |
$observer->setResult($result);
|
128 |
}
|
131 |
return $observer;
|
132 |
}
|
133 |
|
134 |
+
/**
|
135 |
+
* Unflag customer address previously validated
|
136 |
+
*
|
137 |
+
* @see customer_address_save_after
|
138 |
+
* @param Varien_Event_Observer $observer
|
139 |
+
* @return Varien_Event_Observer $observer
|
140 |
+
*/
|
141 |
+
public function updateAddressValidated($observer)
|
142 |
+
{
|
143 |
+
$customerAddress = $observer->getCustomerAddress();
|
144 |
+
|
145 |
+
if (!$customerAddress->getPopulated()){
|
146 |
+
|
147 |
+
$validatedAddress = Mage::getModel('aydus_addressvalidator/address');
|
148 |
+
$validatedAddress->load($customerAddress->getId(), 'address_id');
|
149 |
+
|
150 |
+
$datetime = date('Y-m-d H:i:s');
|
151 |
+
$validatedAddress->setValidated(0);
|
152 |
+
|
153 |
+
if (!$validatedAddress->getId()){
|
154 |
+
$validatedAddress->setDateCreated($datetime);
|
155 |
+
}
|
156 |
+
$validatedAddress->setDateUpdated($datetime);
|
157 |
+
|
158 |
+
try {
|
159 |
+
|
160 |
+
$validatedAddress->save();
|
161 |
+
|
162 |
+
}catch (Exception $e){
|
163 |
+
|
164 |
+
Mage::log($e->getMessage(),null,'aydus_addressvalidator.log');
|
165 |
+
}
|
166 |
+
|
167 |
+
}
|
168 |
+
|
169 |
+
return $observer;
|
170 |
+
}
|
171 |
+
|
172 |
}
|
app/code/community/Aydus/Addressvalidator/Model/Resource/Address.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Address resource model
|
5 |
+
*
|
6 |
+
* @category Aydus
|
7 |
+
* @package Aydus_Addressvalidator
|
8 |
+
* @author Aydus <davidt@aydus.com>
|
9 |
+
*/
|
10 |
+
|
11 |
+
|
12 |
+
class Aydus_Addressvalidator_Model_Resource_Address extends Mage_Core_Model_Resource_Db_Abstract
|
13 |
+
{
|
14 |
+
|
15 |
+
protected function _construct()
|
16 |
+
{
|
17 |
+
$this->_init('aydus_addressvalidator/address', 'id');
|
18 |
+
}
|
19 |
+
|
20 |
+
}
|
21 |
+
|
app/code/community/Aydus/Addressvalidator/Model/Resource/Address/Collection.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Address resource collection
|
5 |
+
*
|
6 |
+
* @category Aydus
|
7 |
+
* @package Aydus_Addressvalidator
|
8 |
+
* @author Aydus <davidt@aydus.com>
|
9 |
+
*/
|
10 |
+
|
11 |
+
|
12 |
+
class Aydus_Addressvalidator_Model_Resource_Address_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
13 |
+
{
|
14 |
+
|
15 |
+
protected function _construct()
|
16 |
+
{
|
17 |
+
parent::_construct();
|
18 |
+
$this->_init('aydus_addressvalidator/address');
|
19 |
+
}
|
20 |
+
|
21 |
+
}
|
app/code/community/Aydus/Addressvalidator/etc/config.xml
CHANGED
@@ -11,7 +11,7 @@
|
|
11 |
<config>
|
12 |
<modules>
|
13 |
<Aydus_Addressvalidator>
|
14 |
-
<version>1.
|
15 |
</Aydus_Addressvalidator>
|
16 |
</modules>
|
17 |
<phpunit>
|
@@ -49,6 +49,16 @@
|
|
49 |
</layout>
|
50 |
</frontend>
|
51 |
<global>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
<blocks>
|
53 |
<aydus_addressvalidator>
|
54 |
<class>Aydus_Addressvalidator_Block</class>
|
@@ -57,7 +67,16 @@
|
|
57 |
<models>
|
58 |
<aydus_addressvalidator>
|
59 |
<class>Aydus_Addressvalidator_Model</class>
|
|
|
60 |
</aydus_addressvalidator>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
</models>
|
62 |
<helpers>
|
63 |
<aydus_addressvalidator>
|
11 |
<config>
|
12 |
<modules>
|
13 |
<Aydus_Addressvalidator>
|
14 |
+
<version>1.4.0</version>
|
15 |
</Aydus_Addressvalidator>
|
16 |
</modules>
|
17 |
<phpunit>
|
49 |
</layout>
|
50 |
</frontend>
|
51 |
<global>
|
52 |
+
<events>
|
53 |
+
<customer_address_save_after>
|
54 |
+
<observers>
|
55 |
+
<addressvalidator_update_address_validated>
|
56 |
+
<class>aydus_addressvalidator/observer</class>
|
57 |
+
<method>updateAddressValidated</method>
|
58 |
+
</addressvalidator_update_address_validated>
|
59 |
+
</observers>
|
60 |
+
</customer_address_save_after>
|
61 |
+
</events>
|
62 |
<blocks>
|
63 |
<aydus_addressvalidator>
|
64 |
<class>Aydus_Addressvalidator_Block</class>
|
67 |
<models>
|
68 |
<aydus_addressvalidator>
|
69 |
<class>Aydus_Addressvalidator_Model</class>
|
70 |
+
<resourceModel>aydus_addressvalidator_resource</resourceModel>
|
71 |
</aydus_addressvalidator>
|
72 |
+
<aydus_addressvalidator_resource>
|
73 |
+
<class>Aydus_Addressvalidator_Model_Resource</class>
|
74 |
+
<entities>
|
75 |
+
<address>
|
76 |
+
<table>aydus_addressvalidator_addresses</table>
|
77 |
+
</address>
|
78 |
+
</entities>
|
79 |
+
</aydus_addressvalidator_resource>
|
80 |
</models>
|
81 |
<helpers>
|
82 |
<aydus_addressvalidator>
|
app/code/community/Aydus/Addressvalidator/sql/aydus_addressvalidator_setup/upgrade-1.3.0-1.4.0.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* 1.4.0 upgrade
|
4 |
+
*
|
5 |
+
* @category Aydus
|
6 |
+
* @package Aydus_Addressvalidator
|
7 |
+
* @author Aydus <davidt@aydus.com>
|
8 |
+
*/
|
9 |
+
|
10 |
+
$this->startSetup();
|
11 |
+
|
12 |
+
$this->run("CREATE TABLE IF NOT EXISTS {$this->getTable('aydus_addressvalidator_addresses')} (
|
13 |
+
`id` INT(11) NOT NULL AUTO_INCREMENT,
|
14 |
+
`address_id` INT(11) NOT NULL,
|
15 |
+
`address_type` ENUM('billing','shipping') NOT NULL,
|
16 |
+
`validated` TINYINT(1) NOT NULL,
|
17 |
+
`date_created` DATETIME NOT NULL,
|
18 |
+
`date_updated` DATETIME NOT NULL,
|
19 |
+
PRIMARY KEY ( `id` )
|
20 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
|
21 |
+
|
22 |
+
$this->endSetup();
|
app/etc/modules/Aydus_Addressvalidator.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Address Validator module
|
5 |
+
*
|
6 |
+
* @category Aydus
|
7 |
+
* @package Aydus_Addressvalidator
|
8 |
+
* @author Aydus <davidt@aydus.com>
|
9 |
+
*/
|
10 |
+
-->
|
11 |
+
<config>
|
12 |
+
<modules>
|
13 |
+
<Aydus_Addressvalidator>
|
14 |
+
<active>true</active>
|
15 |
+
<codePool>community</codePool>
|
16 |
+
</Aydus_Addressvalidator>
|
17 |
+
</modules>
|
18 |
+
</config>
|
package.xml
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Addressvalidator</name>
|
4 |
-
<version>1.
|
5 |
<stability>stable</stability>
|
6 |
-
<license uri="http://
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
-
<summary>Validate billing and shipping addresses in the One Page Checkout.</summary>
|
10 |
-
<description>Validate billing and shipping addresses in the One Page Checkout. Customer submits billing and shipping addresses and is shown a popup of valid addresses to choose from.
|
11 |
-
<notes>
|
12 |
-
<authors><author><name>
|
13 |
-
<date>2015-08-
|
14 |
-
<time>
|
15 |
-
<contents><target name="magecommunity"><dir name="Aydus"><dir name="Addressvalidator"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Form"><file name="Validexceptions.php" hash="cc648c12bc605c14f6127638ceddbe2d"/></dir></dir></dir></dir><dir name="Checkout"><dir name="Onepage"><file name="Billing.php" hash="6be15561b9b09a101bf009734c5ee3a1"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="
|
16 |
<compatible/>
|
17 |
-
<dependencies><required><php><min>5.
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Addressvalidator</name>
|
4 |
+
<version>1.4.0</version>
|
5 |
<stability>stable</stability>
|
6 |
+
<license uri="http://opensource.org/licenses/OSL-3.0">Open Software License</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
+
<summary>Validate billing and shipping addresses in the One Page Checkout. Customer submits billing and shipping addresses and is shown a popup of valid addresses to choose from. With support for UPS, USPS, Fedex, Address Doctor and Melissa Data.</summary>
|
10 |
+
<description>Validate billing and shipping addresses in the One Page Checkout. Customer submits billing and shipping addresses and is shown a popup of valid addresses to choose from. With support for UPS, USPS, Fedex, Address Doctor and Melissa Data.</description>
|
11 |
+
<notes>test notes</notes>
|
12 |
+
<authors><author><name>Extensions Store</name><user>Extension</user><email>admin@extensions-store.com</email></author><author><name>Extensions Store</name><user>Extension</user><email>admin@extensions-store.com</email></author></authors>
|
13 |
+
<date>2015-08-19</date>
|
14 |
+
<time>02:43:46</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="Aydus"><dir name="Addressvalidator"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Form"><file name="Validexceptions.php" hash="cc648c12bc605c14f6127638ceddbe2d"/></dir></dir></dir></dir><dir name="Checkout"><dir name="Onepage"><file name="Billing.php" hash="6be15561b9b09a101bf009734c5ee3a1"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="abf18f7c0106d910901b40887afa75dc"/></dir><dir name="Model"><file name="Address.php" hash="1a8180e69fd0ad58b0fa0d3423c490c0"/><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Source"><dir name="Addressdoctor"><file name="Validcodes.php" hash="fde2d39e5876e12c36857d896cae88c6"/></dir><file name="Service.php" hash="63d35c97530c54ce49deee6a1a746375"/></dir></dir></dir></dir><file name="Observer.php" hash="d98db2d003e6147d66da83e9959b04ff"/><dir name="Resource"><dir name="Address"><file name="Collection.php" hash="f1d88a6e347f83971dd3b41781e8f073"/></dir><file name="Address.php" hash="6638c5f7e07684441c895337c72d6c83"/></dir><dir name="Service"><file name="Abstract.php" hash="281351d7c63b1e92f1cb36f3135f35fb"/><file name="Addressdoctor.php" hash="484ed6246dc1e5ad93cca07d87d76680"/><file name="Fedex.php" hash="1608ae2c935597975816c61dd4a00a90"/><file name="Melissadata.php" hash="629c48b5ab2a40fa177c5a0a2b2e5607"/><file name="Ups.php" hash="9dbcb0dd63eb6bf864b61790fd9d8930"/><file name="Usps.php" hash="f29c986b213806e363a4f51ff19d0c53"/></dir></dir><dir name="Test"><dir name="Controller"><dir name="TestController"><dir name="fixtures"><file name="testController.yaml" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir></dir><file name="TestController.php" hash="b0df7546fc56bd869d805a96e209ee77"/></dir><dir name="Helper"><dir name="TestHelper"><dir name="fixtures"><file name="testHelper.yaml" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir></dir><file name="TestHelper.php" hash="3089d78a75d13084f9482995e807a37f"/></dir><dir name="Model"><dir name="TestModel"><dir name="fixtures"><file name="testModel.yaml" hash="ebcadfcfe7ac7469233f4d5124985792"/></dir></dir><file name="TestModel.php" hash="12609ff92a073dc75d8607482a48c870"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="ec0ecd573275c3b98e98fe85c3d8bbf5"/><file name="config.xml" hash="0cc04a79d550f8b09f09585fe46b26ef"/><file name="system.xml" hash="eb9804849549156ec46460ec0a66db65"/></dir><file name="readme.md" hash="99ee8caa9700fc61ebd943728645896c"/><dir name="sql"><dir name="aydus_addressvalidator_setup"><file name="install-1.0.0.php" hash="a3d556dd3c24a7cc8bad23ed556b61a0"/><file name="upgrade-1.3.0-1.4.0.php" hash="f1d251e2c674b055a991c09dc540ddfb"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="aydus"><file name="addressvalidator.xml" hash="f0610f66ee0426e7b7aff9e4ac90d6da"/></dir></dir><dir name="template"><dir name="aydus"><dir name="addressvalidator"><file name="popup.phtml" hash="5faa92a169c062cc48b248a4c22d55c5"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Aydus_Addressvalidator.xml" hash="b0a4f06b24da23ad6fe75178e987c89d"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="aydus"><file name="addressvalidator.css" hash="c2499e0b4a71cdd7c5456496aefd502b"/></dir></dir><dir name="images"><dir name="aydus"><dir name="addressvalidator"><file name="LOGO_L.gif" hash="5aa294d5345e5b4cc83e92f8ae443283"/><file name="LOGO_S.gif" hash="0654a9638a3b7787f35495ad17dc7363"/></dir></dir></dir><dir name="js"><dir name="aydus"><dir name="addressvalidator"><file name="address.js" hash="5917b0b84e3bae21c347d692d462a0e7"/></dir><file name="addressvalidator.js" hash="6c8ed2034d9555bf2289b76ec2e8a36d"/></dir></dir></dir></dir></dir></target></contents>
|
16 |
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|
skin/frontend/base/default/images/aydus/addressvalidator/LOGO_L.gif
ADDED
Binary file
|
skin/frontend/base/default/images/aydus/addressvalidator/LOGO_S.gif
ADDED
Binary file
|
skin/frontend/base/default/js/aydus/addressvalidator.js
ADDED
@@ -0,0 +1,327 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* Address Validator js
|
3 |
+
*
|
4 |
+
* @category Aydus
|
5 |
+
* @package Aydus_Addressvalidator
|
6 |
+
* @author Aydus <davidt@aydus.com>
|
7 |
+
*/
|
8 |
+
|
9 |
+
function AddressValidator($)
|
10 |
+
{
|
11 |
+
|
12 |
+
var config = {};
|
13 |
+
var results = [];
|
14 |
+
|
15 |
+
/**
|
16 |
+
* select match
|
17 |
+
*
|
18 |
+
* @param string form id
|
19 |
+
* @param string message
|
20 |
+
* @param string resultsJson
|
21 |
+
*/
|
22 |
+
var validateAddress = function (form, message, resultsJson)
|
23 |
+
{
|
24 |
+
//set the popup scope for any js that needs it
|
25 |
+
$('#address-form').val(form);
|
26 |
+
|
27 |
+
//placeholder so address doesn't get validated again
|
28 |
+
var $addressValidated = $('#' + form).find('.address-validated');
|
29 |
+
if ($addressValidated.length > 0) {
|
30 |
+
$addressValidated.val(1);
|
31 |
+
} else {
|
32 |
+
$('#' + form).append('<input type="hidden" class="address-validated" name="address_validated" value="1" />');
|
33 |
+
}
|
34 |
+
|
35 |
+
try {
|
36 |
+
results = JSON.parse(resultsJson);
|
37 |
+
} catch (e) {
|
38 |
+
if (typeof console == 'object') {
|
39 |
+
console.log(e.message);
|
40 |
+
}
|
41 |
+
}
|
42 |
+
|
43 |
+
//create list of addresses and show popup
|
44 |
+
if (results && results.length > 0) {
|
45 |
+
|
46 |
+
//create list of address radio buttons
|
47 |
+
var radios = '';
|
48 |
+
$popup = getPopup();
|
49 |
+
$popup.find('h4').html(message);
|
50 |
+
//show buttons we hid in editAddress
|
51 |
+
$popup.find('.select').show();
|
52 |
+
//hide skip button per JM
|
53 |
+
$popup.find('.skip, .okay').hide();
|
54 |
+
var $radios = $popup.find('ul.radios');
|
55 |
+
$radios.empty();
|
56 |
+
|
57 |
+
var length = results.length;
|
58 |
+
|
59 |
+
for (var i = 0; i < length; i++) {
|
60 |
+
|
61 |
+
var address = results[i];
|
62 |
+
|
63 |
+
var street = (typeof address.street !== 'string' && address.street.length > 1) ? address.street.join(', ') : address.street;
|
64 |
+
var city = (typeof address.city !== 'string' && address.city.length > 1) ? address.city.join(', ') : address.city;
|
65 |
+
|
66 |
+
var addressAr = [street, city, address.region, address.postcode, address.country];
|
67 |
+
addressAr = addressAr.filter(function (n) {
|
68 |
+
return n != undefined
|
69 |
+
});
|
70 |
+
|
71 |
+
var label = addressAr.join(', ');
|
72 |
+
|
73 |
+
radios += '<li><label><input type="radio" class="radio" name="address" value="' + i + '" /> ' + label + '</label></li>';
|
74 |
+
|
75 |
+
}
|
76 |
+
|
77 |
+
//stick into list
|
78 |
+
$radios.append(radios);
|
79 |
+
|
80 |
+
//enable selection
|
81 |
+
$('.radio').click(function (e) {
|
82 |
+
$('#av-popup .select').removeClass('disabled');
|
83 |
+
});
|
84 |
+
|
85 |
+
//show popup
|
86 |
+
$('#av-popup').show();
|
87 |
+
|
88 |
+
}
|
89 |
+
|
90 |
+
};
|
91 |
+
|
92 |
+
/**
|
93 |
+
* No match, edit address
|
94 |
+
*/
|
95 |
+
var editAddress = function (form, message)
|
96 |
+
{
|
97 |
+
//set the popup scope for any js that needs it
|
98 |
+
$('#address-form').val(form);
|
99 |
+
|
100 |
+
if (config.allow_bypass === true){
|
101 |
+
|
102 |
+
$('#' + form).append('<input type="hidden" class="address-validated" name="address_validated" value="1" />');
|
103 |
+
gotoNextStep();
|
104 |
+
|
105 |
+
} else {
|
106 |
+
|
107 |
+
//get the popup
|
108 |
+
$popup = getPopup();
|
109 |
+
//append message
|
110 |
+
$popup.find('h4').html(message);
|
111 |
+
//hide the select button (nothing to select) and skip button (per JM)
|
112 |
+
$popup.find('.select, .skip, .okay').hide();
|
113 |
+
//show popup
|
114 |
+
$('#av-popup').show();
|
115 |
+
}
|
116 |
+
};
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Too many attempts, redirect to url
|
120 |
+
* @param string message
|
121 |
+
* @param string url
|
122 |
+
*/
|
123 |
+
var redirectSupport = function (message, url)
|
124 |
+
{
|
125 |
+
$popup = getPopup();
|
126 |
+
$popup.find('h4').html(message);
|
127 |
+
//hide all buttons except ok
|
128 |
+
$popup.find('.back, .select, .skip').hide();
|
129 |
+
$popup.find('.okay').attr('href', url).show();
|
130 |
+
//show popup
|
131 |
+
$('#av-popup').show();
|
132 |
+
};
|
133 |
+
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Get reset popup
|
137 |
+
*/
|
138 |
+
var getPopup = function ()
|
139 |
+
{
|
140 |
+
var $popup = $('#av-popup');
|
141 |
+
//empty out previous results
|
142 |
+
var $radios = $popup.find('ul.radios');
|
143 |
+
$radios.empty();
|
144 |
+
|
145 |
+
return $popup;
|
146 |
+
};
|
147 |
+
|
148 |
+
var getFormType = function()
|
149 |
+
{
|
150 |
+
var form = $('#address-form').val();
|
151 |
+
var formType;
|
152 |
+
if (form == 'co-billing-form') {
|
153 |
+
formType = 'billing';
|
154 |
+
} else if (form == 'co-shipping-form') {
|
155 |
+
formType = 'shipping';
|
156 |
+
}
|
157 |
+
|
158 |
+
return formType;
|
159 |
+
};
|
160 |
+
|
161 |
+
/**
|
162 |
+
*
|
163 |
+
* @param string formType
|
164 |
+
* @param object address
|
165 |
+
*/
|
166 |
+
var populate = function(formType, address)
|
167 |
+
{
|
168 |
+
//deselect addressbook entry
|
169 |
+
$('#' + formType + '-new-address-form').show();
|
170 |
+
$('#' + formType + '-address-select').val(null);
|
171 |
+
|
172 |
+
$('#' + formType + '\\:street1').val(address.street[0]);
|
173 |
+
|
174 |
+
if (typeof address.street[1] != 'undefined') {
|
175 |
+
$('#' + formType + '\\:street2').val(address.street[1]);
|
176 |
+
}
|
177 |
+
if (typeof address.street[2] != 'undefined') {
|
178 |
+
var street2 = $('#' + formType + '\\:street2').val();
|
179 |
+
$('#' + formType + '\\:street2').val(street2 + ' ' + address.street[2]);
|
180 |
+
}
|
181 |
+
|
182 |
+
var city = (typeof address.city !== 'string' && address.city.length > 1) ? address.city.join(', ') : address.city;
|
183 |
+
|
184 |
+
$('#' + formType + '\\:city').val(city);
|
185 |
+
$('#' + formType + '\\:region').val(address.region);
|
186 |
+
$('#' + formType + '\\:region_id').val(address.region_id);
|
187 |
+
$('#' + formType + '\\:postcode').val(address.postcode);
|
188 |
+
$('#' + formType + '\\:country_id').val(address.country_id);
|
189 |
+
|
190 |
+
$('#' + formType + '\\:save_in_address_book').attr('checked',true);
|
191 |
+
};
|
192 |
+
|
193 |
+
/**
|
194 |
+
* Go to next step
|
195 |
+
*/
|
196 |
+
var gotoNextStep = function ()
|
197 |
+
{
|
198 |
+
var form = $('#address-form').val();
|
199 |
+
|
200 |
+
if (form == 'co-billing-form') {
|
201 |
+
billing.save();
|
202 |
+
} else if (form == 'co-shipping-form') {
|
203 |
+
shipping.save();
|
204 |
+
}
|
205 |
+
};
|
206 |
+
|
207 |
+
|
208 |
+
return {
|
209 |
+
|
210 |
+
init : function(configObj)
|
211 |
+
{
|
212 |
+
config = configObj;
|
213 |
+
|
214 |
+
$(function () {
|
215 |
+
|
216 |
+
$('#co-billing-form input.input-text, #co-billing-form select, #co-shipping-form input.input-text, #co-shipping-form select').change(function (e) {
|
217 |
+
$(this.form).find('.address-validated').val(0);
|
218 |
+
});
|
219 |
+
|
220 |
+
//close the popup and stay on the current step
|
221 |
+
$('#av-popup .back').click(function (e) {
|
222 |
+
|
223 |
+
var form = $('#address-form').val();
|
224 |
+
e.preventDefault();
|
225 |
+
e.stopPropagation();
|
226 |
+
//allow validation
|
227 |
+
$('#' + form).find('.address-validated').val(0);
|
228 |
+
$('#av-popup').hide();
|
229 |
+
|
230 |
+
});
|
231 |
+
|
232 |
+
|
233 |
+
//handle address selection
|
234 |
+
$('#av-popup .select').click(function (e) {
|
235 |
+
|
236 |
+
e.preventDefault();
|
237 |
+
e.stopPropagation();
|
238 |
+
|
239 |
+
var $checkedRadio = $('#av-popup .radio:checked');
|
240 |
+
var checked = ($checkedRadio.length > 0) ? true : false;
|
241 |
+
|
242 |
+
if (checked) {
|
243 |
+
|
244 |
+
var i = $checkedRadio.val();
|
245 |
+
|
246 |
+
if (!isNaN(i)) {
|
247 |
+
|
248 |
+
var formType = getFormType();
|
249 |
+
|
250 |
+
i = parseInt(i);
|
251 |
+
var address = results[i];
|
252 |
+
|
253 |
+
//populate form
|
254 |
+
if (address) {
|
255 |
+
|
256 |
+
populate(formType, address);
|
257 |
+
}
|
258 |
+
|
259 |
+
$('#av-popup').hide();
|
260 |
+
|
261 |
+
gotoNextStep();
|
262 |
+
|
263 |
+
}
|
264 |
+
}
|
265 |
+
|
266 |
+
});
|
267 |
+
|
268 |
+
//skip address validation and continue
|
269 |
+
$('#av-popup .skip').click(function (e) {
|
270 |
+
|
271 |
+
e.preventDefault();
|
272 |
+
e.stopPropagation();
|
273 |
+
|
274 |
+
gotoNextStep();
|
275 |
+
|
276 |
+
$('#av-popup').hide();
|
277 |
+
});
|
278 |
+
|
279 |
+
//too many attempts redirect button
|
280 |
+
$('#av-popup .okay').click(function (e) {
|
281 |
+
|
282 |
+
e.preventDefault();
|
283 |
+
e.stopPropagation();
|
284 |
+
|
285 |
+
var href = $(this).attr('href');
|
286 |
+
|
287 |
+
if (href.indexOf('http') != -1) {
|
288 |
+
|
289 |
+
window.location.href = href;
|
290 |
+
} else {
|
291 |
+
|
292 |
+
window.location.href = 'customer-service';
|
293 |
+
}
|
294 |
+
});
|
295 |
+
|
296 |
+
|
297 |
+
});
|
298 |
+
|
299 |
+
},
|
300 |
+
|
301 |
+
validateAddress : function(form, message, resultsJson)
|
302 |
+
{
|
303 |
+
validateAddress(form, message, resultsJson);
|
304 |
+
},
|
305 |
+
|
306 |
+
editAddress : function(form, message)
|
307 |
+
{
|
308 |
+
editAddress(form, message);
|
309 |
+
},
|
310 |
+
|
311 |
+
redirectSupport : function (message, url)
|
312 |
+
{
|
313 |
+
redirectSupport(message, url);
|
314 |
+
}
|
315 |
+
|
316 |
+
};
|
317 |
+
|
318 |
+
}
|
319 |
+
|
320 |
+
if (!window.jQuery){
|
321 |
+
document.write('<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js">\x3C/script><script>jQuery.noConflict();</script>');
|
322 |
+
document.write('<script>var addressValidator = AddressValidator(jQuery);</script>');
|
323 |
+
} else {
|
324 |
+
var addressValidator = AddressValidator(jQuery);
|
325 |
+
}
|
326 |
+
|
327 |
+
|
skin/frontend/base/default/js/aydus/addressvalidator/address.js
ADDED
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* Address Validator Billing/Shipping prototype overrides
|
3 |
+
*
|
4 |
+
* @category Aydus
|
5 |
+
* @package Aydus_Addressvalidator
|
6 |
+
* @author Aydus <davidt@aydus.com>
|
7 |
+
*/
|
8 |
+
|
9 |
+
if (window.shipping){
|
10 |
+
|
11 |
+
//replace the nextStep method in the Billing prototype
|
12 |
+
var replaceBillingNextStepObj = {
|
13 |
+
nextStep: function (transport) {
|
14 |
+
|
15 |
+
if (transport && transport.responseText) {
|
16 |
+
try {
|
17 |
+
response = eval('(' + transport.responseText + ')');
|
18 |
+
}
|
19 |
+
catch (e) {
|
20 |
+
response = {};
|
21 |
+
}
|
22 |
+
}
|
23 |
+
|
24 |
+
if (response && response.validate) {
|
25 |
+
if (!response.error) {
|
26 |
+
|
27 |
+
if (typeof response.data == 'string') {
|
28 |
+
addressValidator.validateAddress('co-billing-form', response.message, response.data);
|
29 |
+
}
|
30 |
+
} else {
|
31 |
+
if (response.data.indexOf('http') != -1) {
|
32 |
+
addressValidator.redirectSupport(response.message, response.data);
|
33 |
+
} else {
|
34 |
+
addressValidator.editAddress('co-billing-form', response.message);
|
35 |
+
}
|
36 |
+
return false;
|
37 |
+
}
|
38 |
+
}
|
39 |
+
|
40 |
+
if (response.error) {
|
41 |
+
if ((typeof response.message) == 'string') {
|
42 |
+
alert(response.message);
|
43 |
+
} else {
|
44 |
+
if (window.billingRegionUpdater) {
|
45 |
+
billingRegionUpdater.update();
|
46 |
+
}
|
47 |
+
|
48 |
+
alert(response.message.join("\n"));
|
49 |
+
}
|
50 |
+
|
51 |
+
return false;
|
52 |
+
}
|
53 |
+
|
54 |
+
checkout.setStepResponse(response);
|
55 |
+
|
56 |
+
payment.initWhatIsCvvListeners();
|
57 |
+
}
|
58 |
+
|
59 |
+
};
|
60 |
+
|
61 |
+
Billing.addMethods(replaceBillingNextStepObj);
|
62 |
+
//replace the nextStep method in the Shipping prototype
|
63 |
+
var replaceShippingNextStepObj = {
|
64 |
+
nextStep: function (transport) {
|
65 |
+
|
66 |
+
if (transport && transport.responseText) {
|
67 |
+
try {
|
68 |
+
response = eval('(' + transport.responseText + ')');
|
69 |
+
}
|
70 |
+
catch (e) {
|
71 |
+
response = {};
|
72 |
+
}
|
73 |
+
}
|
74 |
+
|
75 |
+
if (response && response.validate) {
|
76 |
+
|
77 |
+
if (!response.error) {
|
78 |
+
if (typeof response.data == 'string') {
|
79 |
+
addressValidator.validateAddress('co-shipping-form', response.message, response.data);
|
80 |
+
}
|
81 |
+
} else {
|
82 |
+
if (response.data.indexOf('http') != -1) {
|
83 |
+
addressValidator.redirectSupport(response.message, response.data);
|
84 |
+
} else {
|
85 |
+
addressValidator.editAddress('co-shipping-form', response.message);
|
86 |
+
}
|
87 |
+
return false;
|
88 |
+
}
|
89 |
+
}
|
90 |
+
|
91 |
+
if (response.error) {
|
92 |
+
if ((typeof response.message) == 'string') {
|
93 |
+
alert(response.message);
|
94 |
+
} else {
|
95 |
+
if (window.shippingRegionUpdater) {
|
96 |
+
shippingRegionUpdater.update();
|
97 |
+
}
|
98 |
+
alert(response.message.join("\n"));
|
99 |
+
}
|
100 |
+
|
101 |
+
return false;
|
102 |
+
}
|
103 |
+
|
104 |
+
checkout.setStepResponse(response);
|
105 |
+
}
|
106 |
+
|
107 |
+
};
|
108 |
+
|
109 |
+
Shipping.addMethods(replaceShippingNextStepObj);
|
110 |
+
}
|