Webshopapps_Matrixrate - Version 4.1.0

Version Notes

Added export facility

Download this release

Release Info

Developer Magento Core Team
Extension Webshopapps_Matrixrate
Version 4.1.0
Comparing to
See all releases


Version 4.1.0

app/code/community/Webshopapps/Matrixrate/Block/Adminhtml/Shipping/Carrier/Matrixrate/Grid.php ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Webshopapps_Matrixrate_Block_Adminhtml_Shipping_Carrier_Matrixrate_Grid extends Mage_Adminhtml_Block_Shipping_Carrier_Tablerate_Grid
5
+ {
6
+
7
+ /**
8
+ * Prepare table columns
9
+ *
10
+ * @return Mage_Adminhtml_Block_Widget_Grid
11
+ */
12
+ protected function _prepareColumns()
13
+ {
14
+ $this->addColumn('dest_country', array(
15
+ 'header' => Mage::helper('adminhtml')->__('Country'),
16
+ 'index' => 'dest_country',
17
+ 'default' => '*',
18
+ ));
19
+
20
+ $this->addColumn('dest_region', array(
21
+ 'header' => Mage::helper('adminhtml')->__('Region/State'),
22
+ 'index' => 'dest_region',
23
+ 'default' => '*',
24
+ ));
25
+
26
+ $this->addColumn('dest_city', array(
27
+ 'header' => Mage::helper('adminhtml')->__('City'),
28
+ 'index' => 'dest_city',
29
+ 'default' => '*',
30
+ ));
31
+
32
+ $this->addColumn('dest_zip', array(
33
+ 'header' => Mage::helper('adminhtml')->__('Zip/Postal Code From'),
34
+ 'index' => 'dest_zip',
35
+ ));
36
+
37
+ $this->addColumn('dest_zip_to', array(
38
+ 'header' => Mage::helper('adminhtml')->__('Zip/Postal Code To'),
39
+ 'index' => 'dest_zip_to',
40
+ ));
41
+
42
+
43
+ $label = Mage::getSingleton('matrixrate/carrier_matrixrate')
44
+ ->getCode('condition_name_short', $this->getConditionName());
45
+
46
+ $this->addColumn('condition_from_value', array(
47
+ 'header' => $label.' From',
48
+ 'index' => 'condition_from_value',
49
+ ));
50
+
51
+ $this->addColumn('condition_to_value', array(
52
+ 'header' => $label.' To',
53
+ 'index' => 'condition_to_value',
54
+ ));
55
+
56
+ $this->addColumn('price', array(
57
+ 'header' => Mage::helper('adminhtml')->__('Shipping Price'),
58
+ 'index' => 'price',
59
+ ));
60
+
61
+ $this->addColumn('delivery_type', array(
62
+ 'header' => Mage::helper('adminhtml')->__('Delivery Type'),
63
+ 'index' => 'delivery_type',
64
+ ));
65
+
66
+ return Mage_Adminhtml_Block_Widget_Grid::_prepareColumns();
67
+ }
68
+
69
+ protected function _prepareCollection()
70
+ {
71
+ $collection = Mage::getResourceModel('matrixrate_shipping/carrier_matrixrate_collection');
72
+ $collection->setConditionFilter($this->getConditionName())
73
+ ->setWebsiteFilter($this->getWebsiteId());
74
+
75
+ $this->setCollection($collection);
76
+
77
+ return Mage_Adminhtml_Block_Widget_Grid::_prepareCollection();
78
+ }
79
+
80
+ }
app/code/community/Webshopapps/Matrixrate/Block/Adminhtml/System/Config/Form/Field/Exportmatrix.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Export CSV button for shipping table rates
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Webshopapps_Matrixrate_Block_Adminhtml_System_Config_Form_Field_Exportmatrix extends Mage_Adminhtml_Block_System_Config_Form_Field
35
+
36
+ {
37
+
38
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
39
+ {
40
+ $this->setElement($element);
41
+
42
+ $buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button');
43
+
44
+ $params = array(
45
+ 'website' => $buttonBlock->getRequest()->getParam('website')
46
+ );
47
+
48
+ $data = array(
49
+ 'label' => Mage::helper('adminhtml')->__('Export CSV'),
50
+
51
+ 'onclick' => 'setLocation(\''.Mage::helper('adminhtml')->getUrl("*/*/exportmatrix", $params) . 'conditionName/\' + $(\'carriers_matrixrate_condition_name\').value + \'/matrixrate.csv\' )',
52
+ 'class' => '',
53
+ );
54
+
55
+ $html = $buttonBlock->setData($data)->toHtml();
56
+
57
+ return $html;
58
+ }
59
+
60
+
61
+ }
app/code/community/Webshopapps/Matrixrate/Helper/Data.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Shipping
23
+ * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ /**
27
+ * Webshopapps Shipping Module
28
+ *
29
+ * NOTICE OF LICENSE
30
+ *
31
+ * This source file is subject to the Open Software License (OSL 3.0)
32
+ * that is bundled with this package in the file LICENSE.txt.
33
+ * It is also available through the world-wide-web at this URL:
34
+ * http://opensource.org/licenses/osl-3.0.php
35
+ * If you did not receive a copy of the license and are unable to
36
+ * obtain it through the world-wide-web, please send an email
37
+ * to license@magentocommerce.com so we can send you a copy immediately.
38
+ *
39
+ * DISCLAIMER
40
+ *
41
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
42
+ * versions in the future. If you wish to customize Magento for your
43
+ * needs please refer to http://www.magentocommerce.com for more information.
44
+ *
45
+ * Shipping MatrixRates
46
+ *
47
+ * @category Webshopapps
48
+ * @package Webshopapps_Matrixrate
49
+ * @copyright Copyright (c) 2010 Zowta Ltd (http://www.webshopapps.com)
50
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
51
+ * @author Karen Baker <sales@webshopapps.com>
52
+ */
53
+
54
+ /**
55
+ * Shipping data helper
56
+ */
57
+ class Webshopapps_Matrixrate_Helper_Data extends Mage_Core_Helper_Abstract
58
+ {
59
+
60
+ }
app/code/community/Webshopapps/Matrixrate/Model/Adminhtml/System/Config/Backend/Shipping/Matrixrate.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Webshopapps Shipping Module
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * Shipping MatrixRates
22
+ *
23
+ * @category Webshopapps
24
+ * @package Webshopapps_Matrixrate
25
+ * @copyright Copyright (c) 2010 Zowta Ltd (http://www.webshopapps.com)
26
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
27
+ * @author Karen Baker <sales@webshopapps.com>
28
+ */
29
+
30
+
31
+ class Webshopapps_Matrixrate_Model_Adminhtml_System_Config_Backend_Shipping_Matrixrate extends Mage_Core_Model_Config_Data
32
+ {
33
+ public function _afterSave()
34
+ {
35
+ Mage::getResourceModel('matrixrate_shipping/carrier_matrixrate')->uploadAndImport($this);
36
+ }
37
+ }
app/code/community/Webshopapps/Matrixrate/Model/Adminhtml/System/Config/Source/Shipping/Matrixrate.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Webshopapps Shipping Module
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * Shipping MatrixRates
22
+ *
23
+ * @category Webshopapps
24
+ * @package Webshopapps_Matrixrate
25
+ * @copyright Copyright (c) 2010 Zowta Ltd (http://www.webshopapps.com)
26
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
27
+ * @author Karen Baker <sales@webshopapps.com>
28
+ */
29
+
30
+ class Webshopapps_Matrixrate_Model_Adminhtml_System_Config_Source_Shipping_Matrixrate
31
+ {
32
+ public function toOptionArray()
33
+ {
34
+
35
+ $tableRate = Mage::getSingleton('matrixrate_shipping/carrier_matrixrate');
36
+ $arr = array();
37
+ foreach ($tableRate->getCode('condition_name') as $k=>$v) {
38
+ $arr[] = array('value'=>$k, 'label'=>$v);
39
+ }
40
+ return $arr;
41
+ }
42
+ }
app/code/community/Webshopapps/Matrixrate/Model/Carrier/Matrixrate.php ADDED
@@ -0,0 +1,216 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Webshopapps Shipping Module
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * Shipping MatrixRates
22
+ *
23
+ * @category Webshopapps
24
+ * @package Webshopapps_Matrixrate
25
+ * @copyright Copyright (c) 2010 Zowta Ltd (http://www.webshopapps.com)
26
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
27
+ * @author Karen Baker <sales@webshopapps.com>
28
+ */
29
+
30
+ class Webshopapps_Matrixrate_Model_Carrier_Matrixrate
31
+ extends Mage_Shipping_Model_Carrier_Abstract
32
+ implements Mage_Shipping_Model_Carrier_Interface
33
+ {
34
+
35
+ protected $_code = 'matrixrate';
36
+ protected $_default_condition_name = 'package_weight';
37
+
38
+ protected $_conditionNames = array();
39
+
40
+ public function __construct()
41
+ {
42
+ parent::__construct();
43
+ foreach ($this->getCode('condition_name') as $k=>$v) {
44
+ $this->_conditionNames[] = $k;
45
+ }
46
+ }
47
+
48
+ /**
49
+ * Enter description here...
50
+ *
51
+ * @param Mage_Shipping_Model_Rate_Request $data
52
+ * @return Mage_Shipping_Model_Rate_Result
53
+ */
54
+ public function collectRates(Mage_Shipping_Model_Rate_Request $request)
55
+ {
56
+ if (!$this->getConfigFlag('active')) {
57
+ return false;
58
+ }
59
+
60
+ // exclude Virtual products price from Package value if pre-configured
61
+ if (!$this->getConfigFlag('include_virtual_price') && $request->getAllItems()) {
62
+ foreach ($request->getAllItems() as $item) {
63
+ if ($item->getParentItem()) {
64
+ continue;
65
+ }
66
+ if ($item->getHasChildren() && $item->isShipSeparately()) {
67
+ foreach ($item->getChildren() as $child) {
68
+ if ($child->getProduct()->isVirtual() || $item->getProductType() == 'downloadable') {
69
+ $request->setPackageValue($request->getPackageValue() - $child->getBaseRowTotal());
70
+ }
71
+ }
72
+ } elseif ($item->getProduct()->isVirtual() || $item->getProductType() == 'downloadable') {
73
+ $request->setPackageValue($request->getPackageValue() - $item->getBaseRowTotal());
74
+ }
75
+ }
76
+ }
77
+
78
+ // Free shipping by qty
79
+ $freeQty = 0;
80
+ if ($request->getAllItems()) {
81
+ foreach ($request->getAllItems() as $item) {
82
+ if ($item->getProduct()->isVirtual() || $item->getParentItem()) {
83
+ continue;
84
+ }
85
+
86
+ if ($item->getHasChildren() && $item->isShipSeparately()) {
87
+ foreach ($item->getChildren() as $child) {
88
+ if ($child->getFreeShipping() && !$child->getProduct()->isVirtual()) {
89
+ $freeQty += $item->getQty() * ($child->getQty() - (is_numeric($child->getFreeShipping()) ? $child->getFreeShipping() : 0));
90
+ }
91
+ }
92
+ } elseif ($item->getFreeShipping()) {
93
+ $freeQty += ($item->getQty() - (is_numeric($item->getFreeShipping()) ? $item->getFreeShipping() : 0));
94
+ }
95
+ }
96
+ }
97
+
98
+ if (!$request->getConditionName()) {
99
+ $request->setConditionName($this->getConfigData('condition_name') ? $this->getConfigData('condition_name') : $this->_default_condition_name);
100
+ }
101
+
102
+ // Package weight and qty free shipping
103
+ $oldWeight = $request->getPackageWeight();
104
+ $oldQty = $request->getPackageQty();
105
+
106
+ $request->setPackageWeight($request->getFreeMethodWeight());
107
+ $request->setPackageQty($oldQty - $freeQty);
108
+
109
+ $result = Mage::getModel('shipping/rate_result');
110
+ $ratearray = $this->getRate($request);
111
+
112
+ $freeShipping=false;
113
+
114
+ if (is_numeric($this->getConfigData('free_shipping_threshold')) &&
115
+ $this->getConfigData('free_shipping_threshold')>0 &&
116
+ $request->getPackageValue()>$this->getConfigData('free_shipping_threshold')) {
117
+ $freeShipping=true;
118
+ }
119
+ if ($this->getConfigData('allow_free_shipping_promotions') &&
120
+ ($request->getFreeShipping() === true ||
121
+ $request->getPackageQty() == $this->getFreeBoxes()))
122
+ {
123
+ $freeShipping=true;
124
+ }
125
+ if ($freeShipping)
126
+ {
127
+ $method = Mage::getModel('shipping/rate_result_method');
128
+ $method->setCarrier('matrixrate');
129
+ $method->setCarrierTitle($this->getConfigData('title'));
130
+ $method->setMethod('matrixrate_free');
131
+ $method->setPrice('0.00');
132
+ $method->setMethodTitle($this->getConfigData('free_method_text'));
133
+ $result->append($method);
134
+
135
+ if ($this->getConfigData('show_only_free')) {
136
+ return $result;
137
+ }
138
+ }
139
+
140
+ foreach ($ratearray as $rate)
141
+ {
142
+ if (!empty($rate) && $rate['price'] >= 0) {
143
+ $method = Mage::getModel('shipping/rate_result_method');
144
+
145
+ $method->setCarrier('matrixrate');
146
+ $method->setCarrierTitle($this->getConfigData('title'));
147
+
148
+ $method->setMethod('matrixrate_'.$rate['pk']);
149
+
150
+ $method->setMethodTitle(Mage::helper('matrixrate')->__($rate['delivery_type']));
151
+
152
+ $shippingPrice = $this->getFinalPriceWithHandlingFee($rate['price']);
153
+ $method->setCost($rate['cost']);
154
+ $method->setDeliveryType($rate['delivery_type']);
155
+
156
+ $method->setPrice($shippingPrice);
157
+
158
+ $result->append($method);
159
+ }
160
+ }
161
+
162
+ return $result;
163
+ }
164
+
165
+ public function getRate(Mage_Shipping_Model_Rate_Request $request)
166
+ {
167
+ return Mage::getResourceModel('matrixrate_shipping/carrier_matrixrate')->getNewRate($request,$this->getConfigFlag('zip_range'));
168
+ }
169
+
170
+ /**
171
+ * Get allowed shipping methods
172
+ *
173
+ * @return array
174
+ */
175
+ public function getAllowedMethods()
176
+ {
177
+ return array('matrixrate'=>$this->getConfigData('name'));
178
+ }
179
+
180
+
181
+ public function getCode($type, $code='')
182
+ {
183
+ $codes = array(
184
+
185
+ 'condition_name'=>array(
186
+ 'package_weight' => Mage::helper('shipping')->__('Weight vs. Destination'),
187
+ 'package_value' => Mage::helper('shipping')->__('Price vs. Destination'),
188
+ 'package_qty' => Mage::helper('shipping')->__('# of Items vs. Destination'),
189
+ ),
190
+
191
+ 'condition_name_short'=>array(
192
+ 'package_weight' => Mage::helper('shipping')->__('Weight'),
193
+ 'package_value' => Mage::helper('shipping')->__('Order Subtotal'),
194
+ 'package_qty' => Mage::helper('shipping')->__('# of Items'),
195
+ ),
196
+
197
+ );
198
+
199
+ if (!isset($codes[$type])) {
200
+ throw Mage::exception('Mage_Shipping', Mage::helper('shipping')->__('Invalid Matrix Rate code type: %s', $type));
201
+ }
202
+
203
+ if (''===$code) {
204
+ return $codes[$type];
205
+ }
206
+
207
+ if (!isset($codes[$type][$code])) {
208
+ throw Mage::exception('Mage_Shipping', Mage::helper('shipping')->__('Invalid Matrix Rate code for type %s: %s', $type, $code));
209
+ }
210
+
211
+ return $codes[$type][$code];
212
+ }
213
+
214
+
215
+
216
+ }
app/code/community/Webshopapps/Matrixrate/Model/Mysql4/Carrier/Matrixrate.php ADDED
@@ -0,0 +1,392 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Webshopapps Shipping Module
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * Shipping MatrixRates
22
+ *
23
+ * @category Webshopapps
24
+ * @package Webshopapps_Matrixrate
25
+ * @copyright Copyright (c) 2010 Zowta Ltd (http://www.webshopapps.com)
26
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
27
+ * @author Karen Baker <sales@webshopapps.com>
28
+ */
29
+ class Webshopapps_Matrixrate_Model_Mysql4_Carrier_Matrixrate extends Mage_Core_Model_Mysql4_Abstract
30
+ {
31
+ protected function _construct()
32
+ {
33
+ $this->_init('shipping/matrixrate', 'pk');
34
+ }
35
+
36
+ public function getNewRate(Mage_Shipping_Model_Rate_Request $request,$zipRangeSet=0)
37
+ {
38
+ $read = $this->_getReadAdapter();
39
+ $write = $this->_getWriteAdapter();
40
+
41
+ $postcode = $request->getDestPostcode();
42
+ $table = Mage::getSingleton('core/resource')->getTableName('matrixrate_shipping/matrixrate');
43
+
44
+ if ($zipRangeSet) {
45
+ # Want to search for postcodes within a range
46
+ $zipSearchString = $read->quoteInto(" AND dest_zip<=? ", $postcode).
47
+ $read->quoteInto(" AND dest_zip_to>=? )", $postcode);
48
+ } else {
49
+ $zipSearchString = $read->quoteInto(" AND ? LIKE dest_zip )", $postcode);
50
+ }
51
+
52
+ for ($j=0;$j<10;$j++)
53
+ {
54
+
55
+ $select = $read->select()->from($table);
56
+ switch($j) {
57
+ case 0:
58
+ $select->where(
59
+ $read->quoteInto(" (dest_country_id=? ", $request->getDestCountryId()).
60
+ $read->quoteInto(" AND dest_region_id=? ", $request->getDestRegionId()).
61
+ $read->quoteInto(" AND STRCMP(LOWER(dest_city),LOWER(?)) = 0 ", $request->getDestCity()).
62
+ # $read->quoteInto(" AND ? LIKE dest_zip ) ", $postcode)
63
+ $zipSearchString
64
+ );
65
+ break;
66
+ case 1:
67
+ $select->where(
68
+ $read->quoteInto(" (dest_country_id=? ", $request->getDestCountryId()).
69
+ $read->quoteInto(" AND dest_region_id=? AND dest_city=''", $request->getDestRegionId()).
70
+ $zipSearchString
71
+ );
72
+ break;
73
+ case 2:
74
+ $select->where(
75
+ $read->quoteInto(" (dest_country_id=? ", $request->getDestCountryId()).
76
+ $read->quoteInto(" AND dest_region_id=? ", $request->getDestRegionId()).
77
+ $read->quoteInto(" AND STRCMP(LOWER(dest_city),LOWER(?)) = 0 AND dest_zip='')", $request->getDestCity())
78
+ );
79
+ break;
80
+ case 3:
81
+ $select->where(
82
+ $read->quoteInto(" (dest_country_id=? ", $request->getDestCountryId()).
83
+ $read->quoteInto(" AND STRCMP(LOWER(dest_city),LOWER(?)) = 0 AND dest_region_id='0'", $request->getDestCity()).
84
+ $zipSearchString
85
+ );
86
+ break;
87
+ case 4:
88
+ $select->where(
89
+ $read->quoteInto(" (dest_country_id=? ", $request->getDestCountryId()).
90
+ $read->quoteInto(" AND STRCMP(LOWER(dest_city),LOWER(?)) = 0 AND dest_region_id='0' AND dest_zip='') ", $request->getDestCity())
91
+ );
92
+ break;
93
+ case 5:
94
+ $select->where(
95
+ $read->quoteInto(" (dest_country_id=? AND dest_region_id='0' AND dest_city='' ", $request->getDestCountryId()).
96
+ # $read->quoteInto(" AND ? LIKE dest_zip ) ", $postcode)
97
+ $zipSearchString
98
+ );
99
+ break;
100
+ case 6:
101
+ $select->where(
102
+ $read->quoteInto(" (dest_country_id=? ", $request->getDestCountryId()).
103
+ $read->quoteInto(" AND dest_region_id=? AND dest_city='' AND dest_zip='') ", $request->getDestRegionId())
104
+ );
105
+ break;
106
+
107
+ case 7:
108
+ $select->where(
109
+ $read->quoteInto(" (dest_country_id=? AND dest_region_id='0' AND dest_city='' AND dest_zip='') ", $request->getDestCountryId())
110
+ );
111
+ break;
112
+ case 8:
113
+ $select->where(
114
+ " (dest_country_id='0' AND dest_region_id='0'".
115
+ $zipSearchString
116
+ );
117
+ break;
118
+
119
+ case 9:
120
+ $select->where(
121
+ " (dest_country_id='0' AND dest_region_id='0' AND dest_zip='')"
122
+ );
123
+ break;
124
+ }
125
+
126
+
127
+ if (is_array($request->getConditionName())) {
128
+ $i = 0;
129
+ foreach ($request->getConditionName() as $conditionName) {
130
+ if ($i == 0) {
131
+ $select->where('condition_name=?', $conditionName);
132
+ } else {
133
+ $select->orWhere('condition_name=?', $conditionName);
134
+ }
135
+ $select->where('condition_from_value<=?', $request->getData($conditionName));
136
+
137
+
138
+ $i++;
139
+ }
140
+ } else {
141
+ $select->where('condition_name=?', $request->getConditionName());
142
+ $select->where('condition_from_value<=?', $request->getData($request->getConditionName()));
143
+ $select->where('condition_to_value>=?', $request->getData($request->getConditionName()));
144
+ }
145
+
146
+ $select->where('website_id=?', $request->getWebsiteId());
147
+
148
+ $select->order('dest_country_id DESC');
149
+ $select->order('dest_region_id DESC');
150
+ $select->order('dest_zip DESC');
151
+ $select->order('condition_from_value DESC');
152
+ /*
153
+ pdo has an issue. we cannot use bind
154
+ */
155
+
156
+ $newdata=array();
157
+ $row = $read->fetchAll($select);
158
+ if (!empty($row))
159
+ {
160
+ // have found a result or found nothing and at end of list!
161
+ foreach ($row as $data) {
162
+ $newdata[]=$data;
163
+ }
164
+ break;
165
+ }
166
+ }
167
+ return $newdata;
168
+
169
+ }
170
+
171
+ public function uploadAndImport(Varien_Object $object)
172
+ {
173
+ $csvFile = $_FILES["groups"]["tmp_name"]["matrixrate"]["fields"]["import"]["value"];
174
+
175
+ if (!empty($csvFile)) {
176
+
177
+ $csv = trim(file_get_contents($csvFile));
178
+
179
+ $table = Mage::getSingleton('core/resource')->getTableName('matrixrate_shipping/matrixrate');
180
+
181
+ $websiteId = $object->getScopeId();
182
+ $websiteModel = Mage::app()->getWebsite($websiteId);
183
+ /*
184
+ getting condition name from post instead of the following commented logic
185
+ */
186
+
187
+ if (isset($_POST['groups']['matrixrate']['fields']['condition_name']['inherit'])) {
188
+ $conditionName = (string)Mage::getConfig()->getNode('default/carriers/matrixrate/condition_name');
189
+ } else {
190
+ $conditionName = $_POST['groups']['matrixrate']['fields']['condition_name']['value'];
191
+ }
192
+
193
+ // $conditionName = $object->getValue();
194
+ // if ($conditionName{0} == '_') {
195
+ // $conditionName = Mage::helper('core/string')->substr($conditionName, 1, strpos($conditionName, '/')-1);
196
+ // } else {
197
+ // $conditionName = $websiteModel->getConfig('carriers/matrixrate/condition_name');
198
+ // }
199
+ $conditionFullName = Mage::getModel('matrixrate_shipping/carrier_matrixrate')->getCode('condition_name_short', $conditionName);
200
+ if (!empty($csv)) {
201
+ $exceptions = array();
202
+ $csvLines = explode("\n", $csv);
203
+ $csvLine = array_shift($csvLines);
204
+ $csvLine = $this->_getCsvValues($csvLine);
205
+ if (count($csvLine) < 7) {
206
+ $exceptions[0] = Mage::helper('shipping')->__('Invalid Matrix Rates File Format');
207
+ }
208
+
209
+ $countryCodes = array();
210
+ $regionCodes = array();
211
+ foreach ($csvLines as $k=>$csvLine) {
212
+ $csvLine = $this->_getCsvValues($csvLine);
213
+ if (count($csvLine) > 0 && count($csvLine) < 7) {
214
+ $exceptions[0] = Mage::helper('shipping')->__('Invalid Matrix Rates File Format');
215
+ } else {
216
+ $countryCodes[] = $csvLine[0];
217
+ $regionCodes[] = $csvLine[1];
218
+ }
219
+ }
220
+
221
+ if (empty($exceptions)) {
222
+ $data = array();
223
+ $countryCodesToIds = array();
224
+ $regionCodesToIds = array();
225
+ $countryCodesIso2 = array();
226
+
227
+ $countryCollection = Mage::getResourceModel('directory/country_collection')->addCountryCodeFilter($countryCodes)->load();
228
+ foreach ($countryCollection->getItems() as $country) {
229
+ $countryCodesToIds[$country->getData('iso3_code')] = $country->getData('country_id');
230
+ $countryCodesToIds[$country->getData('iso2_code')] = $country->getData('country_id');
231
+ $countryCodesIso2[] = $country->getData('iso2_code');
232
+ }
233
+
234
+ $regionCollection = Mage::getResourceModel('directory/region_collection')
235
+ ->addRegionCodeFilter($regionCodes)
236
+ ->addCountryFilter($countryCodesIso2)
237
+ ->load();
238
+
239
+ foreach ($regionCollection->getItems() as $region) {
240
+ $regionCodesToIds[$countryCodesToIds[$region->getData('country_id')]][$region->getData('code')] = $region->getData('region_id');
241
+ }
242
+
243
+ foreach ($csvLines as $k=>$csvLine) {
244
+
245
+ $csvLine = $this->_getCsvValues($csvLine);
246
+
247
+ if (empty($countryCodesToIds) || !array_key_exists($csvLine[0], $countryCodesToIds)) {
248
+ $countryId = '0';
249
+ if ($csvLine[0] != '*' && $csvLine[0] != '') {
250
+ $exceptions[] = Mage::helper('shipping')->__('Invalid Country "%s" in the Row #%s', $csvLine[0], ($k+1));
251
+ }
252
+ } else {
253
+ $countryId = $countryCodesToIds[$csvLine[0]];
254
+ }
255
+
256
+ if (!isset($countryCodesToIds[$csvLine[0]])
257
+ || !isset($regionCodesToIds[$countryCodesToIds[$csvLine[0]]])
258
+ || !array_key_exists($csvLine[1], $regionCodesToIds[$countryCodesToIds[$csvLine[0]]])) {
259
+ $regionId = '0';
260
+ if ($csvLine[1] != '*' && $csvLine[1] != '') {
261
+ $exceptions[] = Mage::helper('shipping')->__('Invalid Region/State "%s" in the Row #%s', $csvLine[1], ($k+1));
262
+ }
263
+ } else {
264
+ $regionId = $regionCodesToIds[$countryCodesToIds[$csvLine[0]]][$csvLine[1]];
265
+ }
266
+
267
+ if (count($csvLine)==9) {
268
+ // we are searching for postcodes in ranges & including cities
269
+ if ($csvLine[2] == '*' || $csvLine[2] == '') {
270
+ $city = '';
271
+ } else {
272
+ $city = $csvLine[2];
273
+ }
274
+
275
+
276
+ if ($csvLine[3] == '*' || $csvLine[3] == '') {
277
+ $zip = '';
278
+ } else {
279
+ $zip = $csvLine[3];
280
+ }
281
+
282
+
283
+ if ($csvLine[4] == '*' || $csvLine[4] == '') {
284
+ $zip_to = '';
285
+ } else {
286
+ $zip_to = $csvLine[4];
287
+ }
288
+
289
+
290
+ if (!$this->_isPositiveDecimalNumber($csvLine[5]) || $csvLine[5] == '*' || $csvLine[5] == '') {
291
+ $exceptions[] = Mage::helper('shipping')->__('Invalid %s From "%s" in the Row #%s', $conditionFullName, $csvLine[5], ($k+1));
292
+ } else {
293
+ $csvLine[5] = (float)$csvLine[5];
294
+ }
295
+
296
+ if (!$this->_isPositiveDecimalNumber($csvLine[6])) {
297
+ $exceptions[] = Mage::helper('shipping')->__('Invalid %s To "%s" in the Row #%s', $conditionFullName, $csvLine[6], ($k+1));
298
+ } else {
299
+ $csvLine[6] = (float)$csvLine[6];
300
+ }
301
+
302
+
303
+ $data[] = array('website_id'=>$websiteId, 'dest_country_id'=>$countryId, 'dest_region_id'=>$regionId, 'dest_city'=>$city, 'dest_zip'=>$zip, 'dest_zip_to'=>$zip_to, 'condition_name'=>$conditionName, 'condition_from_value'=>$csvLine[5],'condition_to_value'=>$csvLine[6], 'price'=>$csvLine[7], 'delivery_type'=>$csvLine[8]);
304
+
305
+ }
306
+ else {
307
+
308
+ if ($csvLine[2] == '*' || $csvLine[2] == '') {
309
+ $zip = '';
310
+ } else {
311
+ $zip = $csvLine[2]."%";
312
+ }
313
+
314
+ $city='';
315
+ $zip_to = '';
316
+
317
+ if (!$this->_isPositiveDecimalNumber($csvLine[3]) || $csvLine[3] == '*' || $csvLine[3] == '') {
318
+ $exceptions[] = Mage::helper('shipping')->__('Invalid %s From "%s" in the Row #%s', $conditionFullName, $csvLine[3], ($k+1));
319
+ } else {
320
+ $csvLine[3] = (float)$csvLine[3];
321
+ }
322
+
323
+ if (!$this->_isPositiveDecimalNumber($csvLine[4])) {
324
+ $exceptions[] = Mage::helper('shipping')->__('Invalid %s To "%s" in the Row #%s', $conditionFullName, $csvLine[4], ($k+1));
325
+ } else {
326
+ $csvLine[4] = (float)$csvLine[4];
327
+ }
328
+ $data[] = array('website_id'=>$websiteId, 'dest_country_id'=>$countryId, 'dest_region_id'=>$regionId, 'dest_city'=>$city,'dest_zip'=>$zip,'dest_zip_to'=>$zip_to, 'condition_name'=>$conditionName, 'condition_from_value'=>$csvLine[3],'condition_to_value'=>$csvLine[4], 'price'=>$csvLine[5], 'delivery_type'=>$csvLine[6]);
329
+ }
330
+
331
+
332
+ $dataDetails[] = array('country'=>$csvLine[0], 'region'=>$csvLine[1]);
333
+
334
+ }
335
+ }
336
+ if (empty($exceptions)) {
337
+ $connection = $this->_getWriteAdapter();
338
+
339
+
340
+ $condition = array(
341
+ $connection->quoteInto('website_id = ?', $websiteId),
342
+ $connection->quoteInto('condition_name = ?', $conditionName),
343
+ );
344
+ $connection->delete($table, $condition);
345
+
346
+ foreach($data as $k=>$dataLine) {
347
+ try {
348
+ $connection->insert($table, $dataLine);
349
+ } catch (Exception $e) {
350
+ $exceptions[] = Mage::helper('shipping')->__('Duplicate Row #%s (Country "%s", Region/State "%s", City "%s", Zip From "%s", Zip To "%s", Delivery Type "%s", Value From "%s" and Value To "%s")', ($k+1), $dataDetails[$k]['country'], $dataDetails[$k]['region'], $dataLine['dest_city'], $dataLine['dest_zip'], $dataLine['dest_zip_to'], $dataLine['delivery_type'], $dataLine['condition_from_value'], $dataLine['condition_to_value']);
351
+ }
352
+ }
353
+ }
354
+ if (!empty($exceptions)) {
355
+ throw new Exception( "\n" . implode("\n", $exceptions) );
356
+ }
357
+ }
358
+ }
359
+ }
360
+
361
+ private function _getCsvValues($string, $separator=",")
362
+ {
363
+ $elements = explode($separator, trim($string));
364
+ for ($i = 0; $i < count($elements); $i++) {
365
+ $nquotes = substr_count($elements[$i], '"');
366
+ if ($nquotes %2 == 1) {
367
+ for ($j = $i+1; $j < count($elements); $j++) {
368
+ if (substr_count($elements[$j], '"') > 0) {
369
+ // Put the quoted string's pieces back together again
370
+ array_splice($elements, $i, $j-$i+1, implode($separator, array_slice($elements, $i, $j-$i+1)));
371
+ break;
372
+ }
373
+ }
374
+ }
375
+ if ($nquotes > 0) {
376
+ // Remove first and last quotes, then merge pairs of quotes
377
+ $qstr =& $elements[$i];
378
+ $qstr = substr_replace($qstr, '', strpos($qstr, '"'), 1);
379
+ $qstr = substr_replace($qstr, '', strrpos($qstr, '"'), 1);
380
+ $qstr = str_replace('""', '"', $qstr);
381
+ }
382
+ $elements[$i] = trim($elements[$i]);
383
+ }
384
+ return $elements;
385
+ }
386
+
387
+ private function _isPositiveDecimalNumber($n)
388
+ {
389
+ return preg_match ("/^[0-9]+(\.[0-9]*)?$/", $n);
390
+ }
391
+
392
+ }
app/code/community/Webshopapps/Matrixrate/Model/Mysql4/Carrier/Matrixrate/Collection.php ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Webshopapps Shipping Module
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * Shipping MatrixRates
22
+ *
23
+ * @category Webshopapps
24
+ * @package Webshopapps_Matrixrate
25
+ * @copyright Copyright (c) 2010 Zowta Ltd (http://www.webshopapps.com)
26
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
27
+ * @author Karen Baker <sales@webshopapps.com>
28
+ */
29
+ class Webshopapps_Matrixrate_Model_Mysql4_Carrier_Matrixrate_Collection extends Varien_Data_Collection_Db
30
+ {
31
+ protected $_shipTable;
32
+ protected $_countryTable;
33
+ protected $_regionTable;
34
+
35
+ public function __construct()
36
+ {
37
+ parent::__construct(Mage::getSingleton('core/resource')->getConnection('shipping_read'));
38
+ $this->_shipTable = Mage::getSingleton('core/resource')->getTableName('matrixrate_shipping/matrixrate');
39
+ $this->_countryTable = Mage::getSingleton('core/resource')->getTableName('directory/country');
40
+ $this->_regionTable = Mage::getSingleton('core/resource')->getTableName('directory/country_region');
41
+ $this->_select->from(array("s" => $this->_shipTable))
42
+ ->joinLeft(array("c" => $this->_countryTable), 'c.country_id = s.dest_country_id', 'iso3_code AS dest_country')
43
+ ->joinLeft(array("r" => $this->_regionTable), 'r.region_id = s.dest_region_id', 'code AS dest_region')
44
+ ->order(array("dest_country", "dest_region", "dest_zip"));
45
+ $this->_setIdFieldName('pk');
46
+ return $this;
47
+ }
48
+
49
+ public function setWebsiteFilter($websiteId)
50
+ {
51
+ $this->_select->where("website_id = ?", $websiteId);
52
+
53
+ return $this;
54
+ }
55
+
56
+ public function setConditionFilter($conditionName)
57
+ {
58
+ $this->_select->where("condition_name = ?", $conditionName);
59
+ return $this;
60
+ }
61
+
62
+ public function setCountryFilter($countryId)
63
+ {
64
+ $this->_select->where("dest_country_id = ?", $countryId);
65
+
66
+ return $this;
67
+ }
68
+ }
app/code/community/Webshopapps/Matrixrate/controllers/System/ConfigController.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * config controller
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Adminhtml
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Webshopapps_Matrixrate_System_ConfigController extends Mage_Adminhtml_Controller_Action
36
+ {
37
+
38
+
39
+ /**
40
+ * Export shipping table rates in csv format
41
+ *
42
+ */
43
+ public function exportmatrixAction()
44
+ {
45
+ $fileName = 'matrixrates.csv';
46
+ /** @var $gridBlock Mage_Adminhtml_Block_Shipping_Carrier_Tablerate_Grid */
47
+ $gridBlock = $this->getLayout()->createBlock('matrixrate_adminhtml/shipping_carrier_matrixrate_grid');
48
+ $website = Mage::app()->getWebsite($this->getRequest()->getParam('website'));
49
+ if ($this->getRequest()->getParam('conditionName')) {
50
+ $conditionName = $this->getRequest()->getParam('conditionName');
51
+ } else {
52
+ $conditionName = $website->getConfig('carriers/matrixrate/condition_name');
53
+ }
54
+ $gridBlock->setWebsiteId($website->getId())->setConditionName($conditionName);
55
+ $content = $gridBlock->getCsvFile();
56
+ $this->_prepareDownloadResponse($fileName, $content);
57
+ }
58
+
59
+ }
app/code/community/Webshopapps/Matrixrate/etc/config.xml ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Webshopapps Shipping Module
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * DISCLAIMER
17
+ *
18
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
19
+ * versions in the future. If you wish to customize Magento for your
20
+ * needs please refer to http://www.magentocommerce.com for more information.
21
+ *
22
+ * Shipping MatrixRates
23
+ *
24
+ * @category Webshopapps
25
+ * @package Webshopapps_Matrixrate
26
+ * @copyright Copyright (c) 2010 Zowta Ltd (http://www.webshopapps.com)
27
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
28
+ * @author Karen Baker <sales@webshopapps.com>
29
+ */
30
+
31
+ -->
32
+ <config>
33
+ <modules>
34
+ <Webshopapps_Matrixrate>
35
+ <version>2.0.2</version>
36
+ </Webshopapps_Matrixrate>
37
+ </modules>
38
+ <global>
39
+ <blocks>
40
+ <matrixrate_adminhtml>
41
+ <class>Webshopapps_Matrixrate_Block_Adminhtml</class>
42
+ </matrixrate_adminhtml>
43
+ </blocks>
44
+ <helpers>
45
+ <matrixrate>
46
+ <class>Webshopapps_Matrixrate_Helper</class>
47
+ </matrixrate>
48
+ </helpers>
49
+ <models>
50
+ <matrixrate>
51
+ <class>Webshopapps_Matrixrate_Model</class>
52
+ </matrixrate>
53
+ <matrixrate_adminhtml>
54
+ <class>Webshopapps_Matrixrate_Model_Adminhtml</class>
55
+ </matrixrate_adminhtml>
56
+ <matrixrate_shipping>
57
+ <class>Webshopapps_Matrixrate_Model</class>
58
+ <resourceModel>matrixrate_mysql4</resourceModel>
59
+ </matrixrate_shipping>
60
+ <matrixrate_mysql4>
61
+ <class>Webshopapps_Matrixrate_Model_Mysql4</class>
62
+ <entities>
63
+ <matrixrate>
64
+ <table>shipping_matrixrate</table>
65
+ </matrixrate>
66
+ </entities>
67
+ </matrixrate_mysql4>
68
+ </models>
69
+ <resources>
70
+ <matrixrate_setup>
71
+ <setup>
72
+ <module>Webshopapps_Matrixrate</module>
73
+ </setup>
74
+ <connection>
75
+ <use>core_setup</use>
76
+ </connection>
77
+ <matrixrate_write>
78
+ <connection>
79
+ <use>core_write</use>
80
+ </connection>
81
+ </matrixrate_write>
82
+ <matrixrate_read>
83
+ <connection>
84
+ <use>core_read</use>
85
+ </connection>
86
+ </matrixrate_read>
87
+ </matrixrate_setup>
88
+ </resources>
89
+ <sales>
90
+ <shipping>
91
+ <carriers>
92
+ <matrixrate>
93
+ <class>Webshopapps_Matrixrate_Model_Carrier_Matrixrate</class>
94
+ </matrixrate>
95
+ </carriers>
96
+ </shipping>
97
+ </sales>
98
+ <helpers>
99
+ <matrixrate>
100
+ <class>Webshopapps_Matrixrate_Helper</class>
101
+ </matrixrate>
102
+ </helpers>
103
+ </global>
104
+ <frontend>
105
+
106
+ <translate>
107
+ <modules>
108
+ <Webshopapps_Matrixrate>
109
+ <files>
110
+ <default>Webshopapps_Matrixrate.csv</default>
111
+ </files>
112
+ </Webshopapps_Matrixrate>
113
+ </modules>
114
+ </translate>
115
+ </frontend>
116
+ <admin>
117
+ <routers>
118
+ <adminhtml>
119
+ <args>
120
+ <modules>
121
+ <Webshopapps_Matrixrate before="Mage_Adminhtml">Webshopapps_Matrixrate</Webshopapps_Matrixrate>
122
+ </modules>
123
+ </args>
124
+ </adminhtml>
125
+ </routers>
126
+ </admin>
127
+ <adminhtml>
128
+ <translate>
129
+
130
+ <modules>
131
+ <Webshopapps_Matrixrate>
132
+ <files>
133
+ <default>Webshopapps_Matrixrate.csv</default>
134
+ </files>
135
+ </Webshopapps_Matrixrate>
136
+ </modules>
137
+ </translate>
138
+ </adminhtml>
139
+ <default>
140
+ <carriers>
141
+ <matrixrate>
142
+ <condition_name>package_weight</condition_name>
143
+ <active>0</active>
144
+ <include_virtual_price>1</include_virtual_price>
145
+ <sallowspecific>0</sallowspecific>
146
+ <allow_free_shipping_promotions>1</allow_free_shipping_promotions>
147
+ <show_only_free>0</show_only_free>
148
+ <free_method_text>Free Shipping</free_method_text>
149
+ <cutoff_cost>50</cutoff_cost>
150
+ <model>matrixrate_shipping/carrier_matrixrate</model>
151
+ <name>MatrixRate</name>
152
+ <title>Select Shipping Method</title>
153
+ <specificerrmsg>This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us.</specificerrmsg>
154
+ </matrixrate>
155
+ </carriers>
156
+ </default>
157
+ </config>
app/code/community/Webshopapps/Matrixrate/etc/system.xml ADDED
@@ -0,0 +1,233 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Webshopapps Shipping Module
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * DISCLAIMER
17
+ *
18
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
19
+ * versions in the future. If you wish to customize Magento for your
20
+ * needs please refer to http://www.magentocommerce.com for more information.
21
+ *
22
+ * Shipping MatrixRates
23
+ *
24
+ * @category Webshopapps
25
+ * @package Webshopapps_Matrixrate
26
+ * @copyright Copyright (c) 2010 Zowta Ltd (http://www.webshopapps.com)
27
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
28
+ * @author Karen Baker <sales@webshopapps.com>
29
+ */
30
+
31
+ -->
32
+ <config>
33
+ <sections>
34
+ <carriers translate="label" module="shipping">
35
+ <groups>
36
+ <matrixrate translate="label">
37
+ <label>Webshopapps Matrix Rates</label>
38
+ <frontend_type>text</frontend_type>
39
+ <sort_order>2</sort_order>
40
+ <show_in_default>1</show_in_default>
41
+ <show_in_website>1</show_in_website>
42
+ <show_in_store>1</show_in_store>
43
+ <comment>
44
+ <![CDATA[
45
+ <div style="padding:10px;background-color:#fff;border:1px solid #ddd;margin-bottom:7px;">
46
+ This module was developed by <a href="http://www.webshopapps.com" target="_blank">www.WebShopApps.com</a> - <b>Magento Shipping Extension Specialists</b>.
47
+ <br/>For docs & examples refer to the WebShopApps <a href="https://sites.google.com/a/webshopapps.com/webshopapps-wiki/extensions/matrix-rates">wiki</a>.
48
+ <br/>We offer <a href="http://webshopapps.com/shipping-extensions/most-popular/premium-matrixrate-shipping-extension.html" target="_blank">Premium Matrixrate</a> for our commercial users, masses of features to reduce maintenance time.
49
+ <br/>We have the largest selections of <a href="http://www.webshopapps.com" target="_blank">shipping extensions</a> on Magento.</a>
50
+ </div>
51
+ ]]>
52
+ </comment>
53
+ <fields>
54
+ <active translate="label">
55
+ <label>Enabled</label>
56
+ <frontend_type>select</frontend_type>
57
+ <source_model>adminhtml/system_config_source_yesno</source_model>
58
+ <sort_order>10</sort_order>
59
+ <show_in_default>1</show_in_default>
60
+ <show_in_website>1</show_in_website>
61
+ <show_in_store>1</show_in_store>
62
+ </active>
63
+ <title translate="label">
64
+ <label>Title</label>
65
+ <frontend_type>text</frontend_type>
66
+ <sort_order>20</sort_order>
67
+ <show_in_default>1</show_in_default>
68
+ <show_in_website>1</show_in_website>
69
+ <show_in_store>1</show_in_store>
70
+ </title>
71
+ <condition_name translate="label">
72
+ <label>Condition</label>
73
+ <frontend_type>select</frontend_type>
74
+ <source_model>matrixrate_adminhtml/system_config_source_shipping_matrixrate</source_model>
75
+ <sort_order>30</sort_order>
76
+ <tooltip>
77
+ Once you change this and save you must re-import csv for it to take effect.
78
+ </tooltip>
79
+ <show_in_default>1</show_in_default>
80
+ <show_in_website>1</show_in_website>
81
+ <show_in_store>0</show_in_store>
82
+ <comment>Filter prices based on destination AND weight, price or quantity</comment>
83
+ </condition_name>
84
+ <import translate="label">
85
+ <label>Import</label>
86
+ <frontend_type>import</frontend_type>
87
+ <backend_model>matrixrate_adminhtml/system_config_backend_shipping_matrixrate</backend_model>
88
+ <sort_order>40</sort_order>
89
+ <show_in_default>0</show_in_default>
90
+ <show_in_website>1</show_in_website>
91
+ <show_in_store>0</show_in_store>
92
+ </import>
93
+ <export translate="label">
94
+ <label>Export</label>
95
+ <frontend_model>matrixrate_adminhtml/system_config_form_field_exportmatrix</frontend_model>
96
+ <sort_order>50</sort_order>
97
+ <show_in_default>0</show_in_default>
98
+ <show_in_website>1</show_in_website>
99
+ <show_in_store>0</show_in_store>
100
+ </export>
101
+ <zip_range translate="label">
102
+ <label>Use zipcode to/from range</label>
103
+ <frontend_type>select</frontend_type>
104
+ <source_model>adminhtml/system_config_source_yesno</source_model>
105
+ <sort_order>60</sort_order>
106
+ <show_in_default>1</show_in_default>
107
+ <show_in_website>1</show_in_website>
108
+ <show_in_store>1</show_in_store>
109
+ <comment>You should only set this to Yes if you use purely numeric zipcodes (e.g. USA/AUS clients)</comment>
110
+ </zip_range>
111
+ <allow_free_shipping_promotions translate="label">
112
+ <label>Free shipping promotions</label>
113
+ <frontend_type>select</frontend_type>
114
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
115
+ <sort_order>70</sort_order>
116
+ <tooltip>
117
+ Allow free shipping promotions to apply to matrixrate
118
+ </tooltip>
119
+ <show_in_default>1</show_in_default>
120
+ <show_in_website>1</show_in_website>
121
+ <show_in_store>1</show_in_store>
122
+ </allow_free_shipping_promotions>
123
+ <show_only_free translate="label">
124
+ <label>Only display free shipping</label>
125
+ <frontend_type>select</frontend_type>
126
+ <source_model>adminhtml/system_config_source_yesno</source_model>
127
+ <tooltip>
128
+ If free shipping applies dont show other shipping rates
129
+ </tooltip>
130
+ <sort_order>80</sort_order>
131
+ <show_in_default>1</show_in_default>
132
+ <show_in_website>1</show_in_website>
133
+ <show_in_store>1</show_in_store>
134
+ </show_only_free>
135
+ <free_method_text translate="label">
136
+ <label>Free shipping display text</label>
137
+ <frontend_type>text</frontend_type>
138
+ <sort_order>90</sort_order>
139
+ <tooltip>
140
+ What to show the shipping as when the price of shipping is 0. I.e "FREE SHIPPING"
141
+ </tooltip>
142
+ <show_in_default>1</show_in_default>
143
+ <show_in_website>1</show_in_website>
144
+ <show_in_store>1</show_in_store>
145
+ </free_method_text>
146
+ <free_shipping_threshold translate="label">
147
+ <label>Minimum order amount for free shipping</label>
148
+ <frontend_type>text</frontend_type>
149
+ <sort_order>100</sort_order>
150
+ <tooltip>
151
+ Apply free shipping if this amount is exceeded
152
+ </tooltip>
153
+ <show_in_default>1</show_in_default>
154
+ <show_in_website>1</show_in_website>
155
+ <show_in_store>1</show_in_store>
156
+ </free_shipping_threshold>
157
+ <include_virtual_price translate="label">
158
+ <label>Include virtual products in price calculation</label>
159
+ <frontend_type>select</frontend_type>
160
+ <source_model>adminhtml/system_config_source_yesno</source_model>
161
+ <sort_order>110</sort_order>
162
+ <show_in_default>1</show_in_default>
163
+ <show_in_website>1</show_in_website>
164
+ <show_in_store>0</show_in_store>
165
+ </include_virtual_price>
166
+ <handling_type translate="label">
167
+ <label>Calculate handling fee</label>
168
+ <frontend_type>select</frontend_type>
169
+ <source_model>shipping/source_handlingType</source_model>
170
+ <sort_order>120</sort_order>
171
+ <show_in_default>1</show_in_default>
172
+ <show_in_website>1</show_in_website>
173
+ <show_in_store>0</show_in_store>
174
+ </handling_type>
175
+ <handling_fee translate="label">
176
+ <label>Handling fee</label>
177
+ <frontend_type>text</frontend_type>
178
+ <sort_order>130</sort_order>
179
+ <show_in_default>1</show_in_default>
180
+ <show_in_website>1</show_in_website>
181
+ <show_in_store>1</show_in_store>
182
+ </handling_fee>
183
+ <sallowspecific translate="label">
184
+ <label>Ship to applicable countries</label>
185
+ <frontend_type>select</frontend_type>
186
+ <sort_order>200</sort_order>
187
+ <frontend_class>shipping-applicable-country</frontend_class>
188
+ <source_model>adminhtml/system_config_source_shipping_allspecificcountries</source_model>
189
+ <show_in_default>1</show_in_default>
190
+ <show_in_website>1</show_in_website>
191
+ <show_in_store>1</show_in_store>
192
+ </sallowspecific>
193
+ <specificcountry translate="label">
194
+ <label>Ship to specific countries</label>
195
+ <frontend_type>multiselect</frontend_type>
196
+ <sort_order>210</sort_order>
197
+ <source_model>adminhtml/system_config_source_country</source_model>
198
+ <show_in_default>1</show_in_default>
199
+ <show_in_website>1</show_in_website>
200
+ <show_in_store>1</show_in_store>
201
+ </specificcountry>
202
+ <showmethod translate="label">
203
+ <label>Show method if not applicable</label>
204
+ <frontend_type>select</frontend_type>
205
+ <sort_order>320</sort_order>
206
+ <frontend_class>shipping-skip-hide</frontend_class>
207
+ <source_model>adminhtml/system_config_source_yesno</source_model>
208
+ <show_in_default>1</show_in_default>
209
+ <show_in_website>1</show_in_website>
210
+ <show_in_store>1</show_in_store>
211
+ </showmethod>
212
+ <specificerrmsg translate="label">
213
+ <label>Displayed error message</label>
214
+ <frontend_type>textarea</frontend_type>
215
+ <sort_order>330</sort_order>
216
+ <show_in_default>1</show_in_default>
217
+ <show_in_website>1</show_in_website>
218
+ <show_in_store>1</show_in_store>
219
+ </specificerrmsg>
220
+ <sort_order translate="label">
221
+ <label>Sort order</label>
222
+ <frontend_type>text</frontend_type>
223
+ <sort_order>500</sort_order>
224
+ <show_in_default>1</show_in_default>
225
+ <show_in_website>1</show_in_website>
226
+ <show_in_store>1</show_in_store>
227
+ </sort_order>
228
+ </fields>
229
+ </matrixrate>
230
+ </groups>
231
+ </carriers>
232
+ </sections>
233
+ </config>
app/code/community/Webshopapps/Matrixrate/sql/matrixrate_setup/mysql4-install-2.0.1.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->run("
8
+
9
+ DROP TABLE IF EXISTS {$this->getTable('shipping_matrixrate')};
10
+ CREATE TABLE {$this->getTable('shipping_matrixrate')} (
11
+ pk int(10) unsigned NOT NULL auto_increment,
12
+ website_id int(11) NOT NULL default '0',
13
+ dest_country_id varchar(4) NOT NULL default '0',
14
+ dest_region_id int(10) NOT NULL default '0',
15
+ dest_city varchar(30) NOT NULL default '',
16
+ dest_zip varchar(10) NOT NULL default '',
17
+ dest_zip_to varchar(10) NOT NULL default '',
18
+ condition_name varchar(20) NOT NULL default '',
19
+ condition_from_value decimal(12,4) NOT NULL default '0.0000',
20
+ condition_to_value decimal(12,4) NOT NULL default '0.0000',
21
+ price decimal(12,4) NOT NULL default '0.0000',
22
+ cost decimal(12,4) NOT NULL default '0.0000',
23
+ delivery_type varchar(255) NOT NULL default '',
24
+ PRIMARY KEY(`pk`),
25
+ UNIQUE KEY `dest_country` (`website_id`,`dest_country_id`,`dest_region_id`,`dest_city`,`dest_zip`,`dest_zip_to`,`condition_name`,`condition_from_value`,`condition_to_value`,`delivery_type`)
26
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
27
+
28
+
29
+
30
+ ");
31
+
32
+ $installer->endSetup();
33
+
34
+
app/code/community/Webshopapps/Matrixrate/sql/matrixrate_setup/mysql4-install-2.0.2.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->run("
8
+
9
+ CREATE TABLE IF NOT EXISTS {$this->getTable('shipping_matrixrate')} (
10
+ pk int(10) unsigned NOT NULL auto_increment,
11
+ website_id int(11) NOT NULL default '0',
12
+ dest_country_id varchar(4) NOT NULL default '0',
13
+ dest_region_id int(10) NOT NULL default '0',
14
+ dest_city varchar(30) NOT NULL default '',
15
+ dest_zip varchar(10) NOT NULL default '',
16
+ dest_zip_to varchar(10) NOT NULL default '',
17
+ condition_name varchar(20) NOT NULL default '',
18
+ condition_from_value decimal(12,4) NOT NULL default '0.0000',
19
+ condition_to_value decimal(12,4) NOT NULL default '0.0000',
20
+ price decimal(12,4) NOT NULL default '0.0000',
21
+ cost decimal(12,4) NOT NULL default '0.0000',
22
+ delivery_type varchar(255) NOT NULL default '',
23
+ PRIMARY KEY(`pk`),
24
+ UNIQUE KEY `dest_country` (`website_id`,`dest_country_id`,`dest_region_id`,`dest_city`,`dest_zip`,`dest_zip_to`,`condition_name`,`condition_from_value`,`condition_to_value`,`delivery_type`)
25
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
26
+
27
+
28
+
29
+ ");
30
+
31
+ $installer->endSetup();
32
+
33
+
app/code/community/Webshopapps/Matrixrate/sql/matrixrate_setup/mysql4-upgrade-2.0.1-2.0.2.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->run("
8
+
9
+ CREATE TABLE IF NOT EXISTS {$this->getTable('shipping_matrixrate')} (
10
+ pk int(10) unsigned NOT NULL auto_increment,
11
+ website_id int(11) NOT NULL default '0',
12
+ dest_country_id varchar(4) NOT NULL default '0',
13
+ dest_region_id int(10) NOT NULL default '0',
14
+ dest_city varchar(30) NOT NULL default '',
15
+ dest_zip varchar(10) NOT NULL default '',
16
+ dest_zip_to varchar(10) NOT NULL default '',
17
+ condition_name varchar(20) NOT NULL default '',
18
+ condition_from_value decimal(12,4) NOT NULL default '0.0000',
19
+ condition_to_value decimal(12,4) NOT NULL default '0.0000',
20
+ price decimal(12,4) NOT NULL default '0.0000',
21
+ cost decimal(12,4) NOT NULL default '0.0000',
22
+ delivery_type varchar(255) NOT NULL default '',
23
+ PRIMARY KEY(`pk`),
24
+ UNIQUE KEY `dest_country` (`website_id`,`dest_country_id`,`dest_region_id`,`dest_city`,`dest_zip`,`dest_zip_to`,`condition_name`,`condition_from_value`,`condition_to_value`,`delivery_type`)
25
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
26
+
27
+
28
+
29
+ ");
30
+
31
+ $installer->endSetup();
32
+
33
+
app/etc/modules/Webshopapps_Matrixrate.xml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Webshopapps_Matrixrate>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ <depends>
8
+ <Mage_Shipping />
9
+ </depends>
10
+ </Webshopapps_Matrixrate>
11
+ </modules>
12
+ </config>
app/locale/en_US/Auctionmaid_Matrixrate.csv ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Calculate Handling Fee","Calculate Handling Fee"
2
+ "Handling Fee","Handling Fee"
3
+ "Enabled","Enabled"
4
+ "Maximum Shipping Cost","Maximum Shipping Cost"
5
+ "Use Zipcode To/From Range","Use Zipcode To/From Range"
6
+ "Import","Import"
7
+ "Free Shipping Text","Free Shipping Text"
8
+ "Sort order","Sort order"
9
+ "Title","Title"
10
+ "Method name","Method name"
11
+ "Ship to applicable countries","Ship to applicable countries"
12
+ "Ship to Specific countries","Ship to Specific countries"
13
+ "Show method if not applicable","Show method if not applicable"
14
+ "Displayed Error Message","Displayed Error Message"
15
+ "Shipping Option","Shipping Option"
package.xml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Webshopapps_Matrixrate</name>
4
+ <version>4.1.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>
8
+ <extends/>
9
+ <summary>Multiple Table Rates via CSV. Filter by country, region,city, zipcode. Numeric Postcode ranges, and enhanced pattern matching supported. Ability to exclude items from free shipping, and specify collection only.</summary>
10
+ <description>Supports following:&#xD;
11
+ &#xD;
12
+ - multiple table rates&#xD;
13
+ - country, region, city, postcode filtering&#xD;
14
+ - partial postcode filtering, including pattern matching&#xD;
15
+ - numerical postcode ranges&#xD;
16
+ - option to exclude items from free shipping&#xD;
17
+ - collection only option</description>
18
+ <notes>Added export facility</notes>
19
+ <authors><author><name>Karen Baker</name><user>auto-converted</user><email>sales@webshopapps.com</email></author></authors>
20
+ <date>2011-04-28</date>
21
+ <time>10:08:04</time>
22
+ <contents><target name="magecommunity"><dir name="Webshopapps"><dir name="Matrixrate"><dir name="Block"><dir name="Adminhtml"><dir name="Shipping"><dir name="Carrier"><dir name="Matrixrate"><file name="Grid.php" hash="50f8e38a0cbfb72543a15d84eb31e4b9"/></dir></dir></dir><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Exportmatrix.php" hash="4ed1f6634f15727205da4e479e84bd91"/></dir></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="97307283fd4c85ed72a699ab4be68661"/></dir><dir name="Model"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Backend"><dir name="Shipping"><file name="Matrixrate.php" hash="d8b6999f8ad837a232ece7a69bc5893f"/></dir></dir><dir name="Source"><dir name="Shipping"><file name="Matrixrate.php" hash="f2914f0d8d36206646e7551ad69736fa"/></dir></dir></dir></dir></dir><dir name="Carrier"><file name="Matrixrate.php" hash="5963c14e89be89371b9ebb2565498268"/></dir><dir name="Mysql4"><dir name="Carrier"><dir name="Matrixrate"><file name="Collection.php" hash="7a4c5d64156700dc82799c5828e4f65c"/></dir><file name="Matrixrate.php" hash="aa5b77ed44de4b973eecccadbe887232"/></dir></dir></dir><dir name="controllers"><dir name="System"><file name="ConfigController.php" hash="5ee3cdd9ea3277607d7a17c327acc9e2"/></dir></dir><dir name="etc"><file name="config.xml" hash="6f5a54c8c08992183ffa01a721f6f6ea"/><file name="system.xml" hash="eb8bc57509351e366ce7843b958acb69"/></dir><dir name="sql"><dir name="matrixrate_setup"><file name="mysql4-install-2.0.1.php" hash="52a413f99ce3d571a067cdfb677bbf32"/><file name="mysql4-install-2.0.2.php" hash="b6530f7e95e610db357ed46bc23629b9"/><file name="mysql4-upgrade-2.0.1-2.0.2.php" hash="b6530f7e95e610db357ed46bc23629b9"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Webshopapps_Matrixrate.xml" hash="ac8b13f26402b2f0e7f6b22c3430fec8"/></dir></target><target name="magelocale"><dir name="en_US"><file name="Auctionmaid_Matrixrate.csv" hash="d72e138554570b1f7d2dd3cec0ef7ce6"/></dir></target></contents>
23
+ <compatible/>
24
+ <dependencies/>
25
+ </package>