Version Notes
Matt Nopobox extension Version 1.1.1 has Released!
Download this release
Release Info
| Developer | Matt |
| Extension | Mage_nopobox |
| Version | 1.1.1 |
| Comparing to | |
| See all releases | |
Code changes from version 1.1.0 to 1.1.1
- app/code/community/Matt/Nopobox/etc/config.xml +1 -1
- app/etc/modules/Matt_Nopobox.xml +9 -0
- package.xml +11 -14
- shell/test.nopobox.php +192 -0
app/code/community/Matt/Nopobox/etc/config.xml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
<config>
|
| 2 |
<modules>
|
| 3 |
<Matt_Nopobox>
|
| 4 |
-
<version>1.1.
|
| 5 |
</Matt_Nopobox>
|
| 6 |
</modules>
|
| 7 |
<global>
|
| 1 |
<config>
|
| 2 |
<modules>
|
| 3 |
<Matt_Nopobox>
|
| 4 |
+
<version>1.1.1</version>
|
| 5 |
</Matt_Nopobox>
|
| 6 |
</modules>
|
| 7 |
<global>
|
app/etc/modules/Matt_Nopobox.xml
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<Matt_Nopobox>
|
| 5 |
+
<active>true</active>
|
| 6 |
+
<codePool>community</codePool>
|
| 7 |
+
</Matt_Nopobox>
|
| 8 |
+
</modules>
|
| 9 |
+
</config>
|
package.xml
CHANGED
|
@@ -1,32 +1,29 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Mage_nopobox</name>
|
| 4 |
-
<version>1.1.
|
| 5 |
<stability>stable</stability>
|
| 6 |
-
<license
|
| 7 |
<channel>community</channel>
|
| 8 |
<extends/>
|
| 9 |
<summary>Check shipping address whether it contains POBOX.</summary>
|
| 10 |
-
<description>The extension updates the Magento checkout fields to prevent shipping to a
|
| 11 |

|
| 12 |
-
<h1
|
| 13 |
<ol><li>install extension ,please follow this pdf <a href="http://info.magento.com/rs/magentocommerce/images/InstallingMagentoConnectExtensions4%200.pdf">Magento Connect Installing Extensions (PDF)</a> .
|
| 14 |
-
</li><li>Go to System-&
|
| 15 |
</li><li>it will works very well!
|
| 16 |
</li></ol>
|
| 17 |
-
|
|
|
|
| 18 |
<ul><li>add admin config option
|
| 19 |
</li><li>add allow country option
|
| 20 |
</li><li>add custom error message option</li></ul></description>
|
| 21 |
-
<notes>Matt Nopobox extension 1.1.
|
| 22 |
-
Features
|
| 23 |
-
1. add admin config option
|
| 24 |
-
2. add allow country option
|
| 25 |
-
3. add custom error message option</notes>
|
| 26 |
<authors><author><name>Matt</name><user>caijiamx</user><email>caijiamx@gmail.com</email></author></authors>
|
| 27 |
-
<date>
|
| 28 |
-
<time>
|
| 29 |
-
<contents><target name="
|
| 30 |
<compatible/>
|
| 31 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
| 32 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Mage_nopobox</name>
|
| 4 |
+
<version>1.1.1</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
+
<license>OSL</license>
|
| 7 |
<channel>community</channel>
|
| 8 |
<extends/>
|
| 9 |
<summary>Check shipping address whether it contains POBOX.</summary>
|
| 10 |
+
<description>The extension updates the Magento checkout fields to prevent shipping to a PO box. It also provides error messaging to inform customers that they must enter a valid shipping address before proceeding through checkout.
|
| 11 |

|
| 12 |
+
<h1>How to install</h1>
|
| 13 |
<ol><li>install extension ,please follow this pdf <a href="http://info.magento.com/rs/magentocommerce/images/InstallingMagentoConnectExtensions4%200.pdf">Magento Connect Installing Extensions (PDF)</a> .
|
| 14 |
+
</li><li>Go to System->Configuration->Matt Module->Matt Nopobox Setting->Options, set Enabled to Yes and save config.
|
| 15 |
</li><li>it will works very well!
|
| 16 |
</li></ol>
|
| 17 |
+

|
| 18 |
+
<h1>Features</h1>
|
| 19 |
<ul><li>add admin config option
|
| 20 |
</li><li>add allow country option
|
| 21 |
</li><li>add custom error message option</li></ul></description>
|
| 22 |
+
<notes>Matt Nopobox extension Version 1.1.1 has Released!</notes>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
<authors><author><name>Matt</name><user>caijiamx</user><email>caijiamx@gmail.com</email></author></authors>
|
| 24 |
+
<date>2013-06-06</date>
|
| 25 |
+
<time>08:48:27</time>
|
| 26 |
+
<contents><target name="mageetc"><dir name="modules"><file name="Matt_Nopobox.xml" hash="912bd655880b9f05869665fe257f1eed"/></dir></target><target name="magecommunity"><dir name="Matt"><dir name="Nopobox"><dir name="Helper"><file name="Data.php" hash="7938eca0ac63785cb781de7f449b939b"/></dir><dir name="Model"><dir name="Quote"><file name="Address.php" hash="124031fbcf90c26a91f03bdf09683333"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="3cf3615c201fccd9f78cd516c2c2efe6"/><file name="config.xml" hash="ad88a97de8a6613d5923798ddf93266e"/><file name="system.xml" hash="ad439be480877a1b7a503c2299e1bad0"/></dir></dir></dir></target><target name="mage"><dir name="shell"><file name="test.nopobox.php" hash="95efa28f9792d368d91d5f8932a0dc15"/></dir></target></contents>
|
| 27 |
<compatible/>
|
| 28 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
| 29 |
</package>
|
shell/test.nopobox.php
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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name(dirname(__FILE__)) . DIRECTORY_SEPARATOR;
|
| 10 |
+
$code = 'admin';
|
| 11 |
+
$type = 'store';
|
| 12 |
+
require_once $path . 'app' . DIRECTORY_SEPARATOR . 'Mage.php';
|
| 13 |
+
Mage::app($code, $type);
|
| 14 |
+
}
|
| 15 |
+
protected function _getTestModel($countryId = 'US' , $RegionId = 43){
|
| 16 |
+
$model = Mage::getModel('Matt_Nopobox_Model_Quote_Address');
|
| 17 |
+
$model->setFirstname('Jia');
|
| 18 |
+
$model->setLastname('Cai');
|
| 19 |
+
$model->setCity('Whaterveer');
|
| 20 |
+
$model->setTelephone('186');
|
| 21 |
+
$model->setCountryId($countryId);
|
| 22 |
+
$model->setPostcode('512443');
|
| 23 |
+
$model->setRegionId($RegionId);
|
| 24 |
+
return $model;
|
| 25 |
+
}
|
| 26 |
+
protected function _setField($field = 'active' , $value = 1){
|
| 27 |
+
$section = 'nopobox';
|
| 28 |
+
$groups = array(
|
| 29 |
+
'option' => array(
|
| 30 |
+
'fields' => array(
|
| 31 |
+
$field => array(
|
| 32 |
+
'value' => $value
|
| 33 |
+
)
|
| 34 |
+
)
|
| 35 |
+
)
|
| 36 |
+
);
|
| 37 |
+
Mage::getModel('adminhtml/config_data')
|
| 38 |
+
->setSection($section)
|
| 39 |
+
//->setWebsite($website)
|
| 40 |
+
//->setStore($store)
|
| 41 |
+
->setGroups($groups)
|
| 42 |
+
->save();
|
| 43 |
+
//$model = Mage::getModel('core/config');
|
| 44 |
+
//$model->saveConfig('nopobox/option/active' , $active);
|
| 45 |
+
// reinit configuration
|
| 46 |
+
Mage::getConfig()->reinit();
|
| 47 |
+
Mage::app()->reinitStores();
|
| 48 |
+
}
|
| 49 |
+
public function testNopoboxEnable(){
|
| 50 |
+
$this->_setField('active' , 0);
|
| 51 |
+
$active = Mage::getStoreConfig('nopobox/option/active');
|
| 52 |
+
$this->assertEquals(0, $active);
|
| 53 |
+
$this->_setField();
|
| 54 |
+
$active = Mage::getStoreConfig('nopobox/option/active');
|
| 55 |
+
$this->assertEquals(1, $active);
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
public function testHasPoboxNoCountry(){
|
| 59 |
+
$this->_setField('allowspecific' , 0);
|
| 60 |
+
$model = $this->_getTestModel();
|
| 61 |
+
$street = array();
|
| 62 |
+
$street[] = 'Futian street';
|
| 63 |
+
$street[] = 'pobox test';
|
| 64 |
+
$model->setStreet($street);
|
| 65 |
+
$errors = $model->validate();
|
| 66 |
+
$_errors =array();
|
| 67 |
+
$_errors[] = Mage::helper('core')->__(Mage::getStoreConfig('nopobox/option/aerror'));
|
| 68 |
+
$this->assertEquals($_errors, $errors);
|
| 69 |
+
|
| 70 |
+
$street = array();
|
| 71 |
+
$street[] = 'pobox test';
|
| 72 |
+
$street[] = 'Futian street';
|
| 73 |
+
$model->setStreet($street);
|
| 74 |
+
$errors = $model->validate();
|
| 75 |
+
$_errors =array();
|
| 76 |
+
$_errors[] = Mage::helper('core')->__(Mage::getStoreConfig('nopobox/option/aerror'));
|
| 77 |
+
$this->assertEquals($_errors, $errors);
|
| 78 |
+
|
| 79 |
+
$street = array();
|
| 80 |
+
$street[] = 'Pobox test';
|
| 81 |
+
$street[] = 'Futian street';
|
| 82 |
+
$model->setStreet($street);
|
| 83 |
+
$errors = $model->validate();
|
| 84 |
+
$_errors =array();
|
| 85 |
+
$_errors[] = Mage::helper('core')->__(Mage::getStoreConfig('nopobox/option/aerror'));
|
| 86 |
+
$this->assertEquals($_errors, $errors);
|
| 87 |
+
|
| 88 |
+
$street = array();
|
| 89 |
+
$street[] = 'POBOX test';
|
| 90 |
+
$street[] = 'Futian street';
|
| 91 |
+
$model->setStreet($street);
|
| 92 |
+
$errors = $model->validate();
|
| 93 |
+
$_errors =array();
|
| 94 |
+
$_errors[] = Mage::helper('core')->__(Mage::getStoreConfig('nopobox/option/aerror'));
|
| 95 |
+
$this->assertEquals($_errors, $errors);
|
| 96 |
+
}
|
| 97 |
+
public function testErrorMerge(){
|
| 98 |
+
$model = $this->_getTestModel();
|
| 99 |
+
$model->setFirstname('');
|
| 100 |
+
$errors = $model->validate();
|
| 101 |
+
$_errors =array();
|
| 102 |
+
$_errors[] = Mage::helper('customer')->__('Please enter the first name.');
|
| 103 |
+
$_errors[] = Mage::helper('customer')->__('Please enter the street.');
|
| 104 |
+
$this->assertEquals($_errors, $errors);
|
| 105 |
+
|
| 106 |
+
//join pobox validate
|
| 107 |
+
$street = array();
|
| 108 |
+
$street[] = 'Futian street';
|
| 109 |
+
$street[] = 'pobox test';
|
| 110 |
+
$model->setStreet($street);
|
| 111 |
+
$errors = $model->validate();
|
| 112 |
+
$_errors =array();
|
| 113 |
+
$_errors[] = Mage::helper('customer')->__('Please enter the first name.');
|
| 114 |
+
$_errors[] = Mage::helper('core')->__(Mage::getStoreConfig('nopobox/option/aerror'));
|
| 115 |
+
$this->assertEquals($_errors, $errors);
|
| 116 |
+
}
|
| 117 |
+
public function testHasPoboxHasCountry(){
|
| 118 |
+
$this->_setField('allowspecific');
|
| 119 |
+
$this->_setField('specificcountry' , array('DE' , 'US'));
|
| 120 |
+
$model = $this->_getTestModel('DE' , 80);
|
| 121 |
+
$street = array();
|
| 122 |
+
$street[] = 'Futian street';
|
| 123 |
+
$street[] = 'Pobox test';
|
| 124 |
+
$model->setStreet($street);
|
| 125 |
+
$errors = $model->validate();
|
| 126 |
+
$this->assertEquals(true, $errors);
|
| 127 |
+
|
| 128 |
+
$street = array();
|
| 129 |
+
$street[] = 'Pobox test';
|
| 130 |
+
$street[] = 'Futian street';
|
| 131 |
+
$model->setStreet($street);
|
| 132 |
+
$errors = $model->validate();
|
| 133 |
+
$this->assertEquals(true, $errors);
|
| 134 |
+
|
| 135 |
+
$street = array();
|
| 136 |
+
$street[] = 'Pobox test';
|
| 137 |
+
$street[] = 'Futian street';
|
| 138 |
+
$model->setStreet($street);
|
| 139 |
+
$errors = $model->validate();
|
| 140 |
+
$this->assertEquals(true, $errors);
|
| 141 |
+
|
| 142 |
+
$street = array();
|
| 143 |
+
$street[] = 'POBOX test';
|
| 144 |
+
$street[] = 'Futian street';
|
| 145 |
+
$model->setStreet($street);
|
| 146 |
+
$errors = $model->validate();
|
| 147 |
+
$this->assertEquals(true, $errors);
|
| 148 |
+
|
| 149 |
+
|
| 150 |
+
//can not use pobox
|
| 151 |
+
$model = $this->_getTestModel('FR' , 200);
|
| 152 |
+
$street = array();
|
| 153 |
+
$street[] = 'Futian street';
|
| 154 |
+
$street[] = 'Pobox test';
|
| 155 |
+
$model->setStreet($street);
|
| 156 |
+
$errors = $model->validate();
|
| 157 |
+
$_errors =array();
|
| 158 |
+
$_errors[] = Mage::helper('core')->__(Mage::getStoreConfig('nopobox/option/cerror'));
|
| 159 |
+
$this->assertEquals($_errors, $errors);
|
| 160 |
+
|
| 161 |
+
$street = array();
|
| 162 |
+
$street[] = 'Pobox test';
|
| 163 |
+
$street[] = 'Futian street';
|
| 164 |
+
$model->setStreet($street);
|
| 165 |
+
$errors = $model->validate();
|
| 166 |
+
$_errors =array();
|
| 167 |
+
$_errors[] = Mage::helper('core')->__(Mage::getStoreConfig('nopobox/option/cerror'));
|
| 168 |
+
$this->assertEquals($_errors, $errors);
|
| 169 |
+
|
| 170 |
+
$street = array();
|
| 171 |
+
$street[] = 'Pobox test';
|
| 172 |
+
$street[] = 'Futian street';
|
| 173 |
+
$model->setStreet($street);
|
| 174 |
+
$errors = $model->validate();
|
| 175 |
+
$_errors =array();
|
| 176 |
+
$_errors[] = Mage::helper('core')->__(Mage::getStoreConfig('nopobox/option/cerror'));
|
| 177 |
+
$this->assertEquals($_errors, $errors);
|
| 178 |
+
|
| 179 |
+
$street = array();
|
| 180 |
+
$street[] = 'POBOX test';
|
| 181 |
+
$street[] = 'Futian street';
|
| 182 |
+
$model->setStreet($street);
|
| 183 |
+
$errors = $model->validate();
|
| 184 |
+
$_errors =array();
|
| 185 |
+
$_errors[] = Mage::helper('core')->__(Mage::getStoreConfig('nopobox/option/cerror'));
|
| 186 |
+
$this->assertEquals($_errors, $errors);
|
| 187 |
+
|
| 188 |
+
$this->_setField('allowspecific' , 0);
|
| 189 |
+
$this->_setField('specificcountry' , array());
|
| 190 |
+
}
|
| 191 |
+
}
|
| 192 |
+
?>
|
