Version Notes
1 - The export csv option is currently disabled. This is so the extension does not conflict with the existing tablerates. There are no plans to resolve this - if you need to view the data look in phpmyadmin.
Download this release
Release Info
| Developer | Magento Core Team |
| Extension | Auctionmaid_Matrxrate |
| Version | 2.0.3 |
| Comparing to | |
| See all releases | |
Code changes from version 2.0.2 to 2.0.3
app/code/community/Auctionmaid/Freeoptionalshipping/Model/Carrier/Freeoptionalshipping.php
CHANGED
|
@@ -20,7 +20,7 @@
|
|
| 20 |
*
|
| 21 |
* Conditional Free Shipping Module - where if attribute exclude_free_shipping is set
|
| 22 |
* will result in free shipping being disabled for checkout
|
| 23 |
-
*
|
| 24 |
* @category Auctionmaid
|
| 25 |
* @package Auctionmaid_Freeoptionalshipping
|
| 26 |
* @copyright Copyright (c) 2008 Auction Maid (http://www.auctionmaid.com)
|
|
@@ -64,6 +64,7 @@ class Auctionmaid_Freeoptionalshipping_Model_Carrier_Freeoptionalshipping
|
|
| 64 |
foreach($items as $item) {
|
| 65 |
$product = Mage::getModel('catalog/product')->loadByAttribute('sku', $item->getSku(), 'exclude_free_shipping');
|
| 66 |
if ($product->getData('exclude_free_shipping')) {
|
|
|
|
| 67 |
return false;
|
| 68 |
}
|
| 69 |
}
|
| 20 |
*
|
| 21 |
* Conditional Free Shipping Module - where if attribute exclude_free_shipping is set
|
| 22 |
* will result in free shipping being disabled for checkout
|
| 23 |
+
*
|
| 24 |
* @category Auctionmaid
|
| 25 |
* @package Auctionmaid_Freeoptionalshipping
|
| 26 |
* @copyright Copyright (c) 2008 Auction Maid (http://www.auctionmaid.com)
|
| 64 |
foreach($items as $item) {
|
| 65 |
$product = Mage::getModel('catalog/product')->loadByAttribute('sku', $item->getSku(), 'exclude_free_shipping');
|
| 66 |
if ($product->getData('exclude_free_shipping')) {
|
| 67 |
+
Mage::log(print_r($item->getSku(),true));
|
| 68 |
return false;
|
| 69 |
}
|
| 70 |
}
|
app/code/community/Auctionmaid/Matrixrate/Model/Mysql4/Carrier/Matrixrate.php
CHANGED
|
@@ -1,365 +1,383 @@
|
|
| 1 |
-
<?php
|
| 2 |
-
/**
|
| 3 |
-
* Magento Auctionmaid 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 Auctionmaid
|
| 24 |
-
* @package Auctionmaid_Matrixrate
|
| 25 |
-
* @copyright Copyright (c) 2008 Auction Maid (http://www.auctionmaid.com)
|
| 26 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 27 |
-
* @author Karen Baker <enquiries@auctionmaid.com>
|
| 28 |
-
*/
|
| 29 |
-
class Auctionmaid_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<
|
| 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=? ", $request->getDestRegionId()).
|
| 70 |
-
$
|
| 71 |
-
);
|
| 72 |
-
break;
|
| 73 |
-
case 2:
|
| 74 |
-
$select->where(
|
| 75 |
-
|
| 76 |
-
$read->quoteInto(" AND
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
$i
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
$
|
| 140 |
-
$
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
$
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
$
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
$
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
$
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
foreach ($
|
| 221 |
-
$
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
if ($csvLine[
|
| 282 |
-
$
|
| 283 |
-
} else {
|
| 284 |
-
$
|
| 285 |
-
}
|
| 286 |
-
|
| 287 |
-
$
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
}
|
| 326 |
-
}
|
| 327 |
-
if (
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Magento Auctionmaid 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 Auctionmaid
|
| 24 |
+
* @package Auctionmaid_Matrixrate
|
| 25 |
+
* @copyright Copyright (c) 2008 Auction Maid (http://www.auctionmaid.com)
|
| 26 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 27 |
+
* @author Karen Baker <enquiries@auctionmaid.com>
|
| 28 |
+
*/
|
| 29 |
+
class Auctionmaid_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<8;$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 |
+
|
| 81 |
+
case 3:
|
| 82 |
+
$select->where(
|
| 83 |
+
$read->quoteInto(" (dest_country_id=? ", $request->getDestCountryId()).
|
| 84 |
+
$read->quoteInto(" AND STRCMP(LOWER(dest_city),LOWER(?)) = 0 AND dest_region_id='0' AND dest_zip='') ", $request->getDestCity())
|
| 85 |
+
);
|
| 86 |
+
break;
|
| 87 |
+
case 4:
|
| 88 |
+
$select->where(
|
| 89 |
+
$read->quoteInto(" (dest_country_id=? AND dest_region_id='0' AND dest_city='' ", $request->getDestCountryId()).
|
| 90 |
+
# $read->quoteInto(" AND ? LIKE dest_zip ) ", $postcode)
|
| 91 |
+
$zipSearchString
|
| 92 |
+
);
|
| 93 |
+
break;
|
| 94 |
+
case 5:
|
| 95 |
+
$select->where(
|
| 96 |
+
$read->quoteInto(" (dest_country_id=? ", $request->getDestCountryId()).
|
| 97 |
+
$read->quoteInto(" AND dest_region_id=? AND dest_city='' AND dest_zip='') ", $request->getDestRegionId())
|
| 98 |
+
);
|
| 99 |
+
break;
|
| 100 |
+
|
| 101 |
+
case 6:
|
| 102 |
+
$select->where(
|
| 103 |
+
$read->quoteInto(" (dest_country_id=? AND dest_region_id='0' AND dest_city='' AND dest_zip='') ", $request->getDestCountryId())
|
| 104 |
+
);
|
| 105 |
+
break;
|
| 106 |
+
|
| 107 |
+
case 7:
|
| 108 |
+
$select->where(
|
| 109 |
+
" (dest_country_id='0' AND dest_region_id='0' AND dest_zip='')"
|
| 110 |
+
);
|
| 111 |
+
break;
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
if (is_array($request->getConditionName())) {
|
| 116 |
+
$i = 0;
|
| 117 |
+
foreach ($request->getConditionName() as $conditionName) {
|
| 118 |
+
if ($i == 0) {
|
| 119 |
+
$select->where('condition_name=?', $conditionName);
|
| 120 |
+
} else {
|
| 121 |
+
$select->orWhere('condition_name=?', $conditionName);
|
| 122 |
+
}
|
| 123 |
+
$select->where('condition_from_value<=?', $request->getData($conditionName));
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
$i++;
|
| 127 |
+
}
|
| 128 |
+
} else {
|
| 129 |
+
$select->where('condition_name=?', $request->getConditionName());
|
| 130 |
+
$select->where('condition_from_value<=?', $request->getData($request->getConditionName()));
|
| 131 |
+
$select->where('condition_to_value>=?', $request->getData($request->getConditionName()));
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
/* Mage::log(print_r($request,true));**/
|
| 135 |
+
$select->where('website_id=?', $request->getWebsiteId());
|
| 136 |
+
|
| 137 |
+
$select->order('dest_country_id DESC');
|
| 138 |
+
$select->order('dest_region_id DESC');
|
| 139 |
+
$select->order('dest_zip DESC');
|
| 140 |
+
$select->order('condition_from_value DESC');
|
| 141 |
+
|
| 142 |
+
/*
|
| 143 |
+
pdo has an issue. we cannot use bind
|
| 144 |
+
*/
|
| 145 |
+
|
| 146 |
+
Mage::log(print_r($select,true));
|
| 147 |
+
|
| 148 |
+
$newdata=array();
|
| 149 |
+
$row = $read->fetchAll($select);
|
| 150 |
+
if (!empty($row))
|
| 151 |
+
{
|
| 152 |
+
// have found a result or found nothing and at end of list!
|
| 153 |
+
foreach ($row as $data) {
|
| 154 |
+
$newdata[]=$data;
|
| 155 |
+
}
|
| 156 |
+
break;
|
| 157 |
+
}
|
| 158 |
+
}
|
| 159 |
+
return $newdata;
|
| 160 |
+
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
public function uploadAndImport(Varien_Object $object)
|
| 164 |
+
{
|
| 165 |
+
$csvFile = $_FILES["groups"]["tmp_name"]["matrixrate"]["fields"]["import"]["value"];
|
| 166 |
+
|
| 167 |
+
if (!empty($csvFile)) {
|
| 168 |
+
|
| 169 |
+
$csv = trim(file_get_contents($csvFile));
|
| 170 |
+
|
| 171 |
+
$table = Mage::getSingleton('core/resource')->getTableName('matrixrate_shipping/matrixrate');
|
| 172 |
+
|
| 173 |
+
$websiteId = $object->getScopeId();
|
| 174 |
+
$websiteModel = Mage::app()->getWebsite($websiteId);
|
| 175 |
+
/*
|
| 176 |
+
getting condition name from post instead of the following commented logic
|
| 177 |
+
*/
|
| 178 |
+
|
| 179 |
+
if (isset($_POST['groups']['matrixrate']['fields']['condition_name']['inherit'])) {
|
| 180 |
+
$conditionName = (string)Mage::getConfig()->getNode('default/carriers/matrixrate/condition_name');
|
| 181 |
+
} else {
|
| 182 |
+
$conditionName = $_POST['groups']['matrixrate']['fields']['condition_name']['value'];
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
// $conditionName = $object->getValue();
|
| 186 |
+
// if ($conditionName{0} == '_') {
|
| 187 |
+
// $conditionName = Mage::helper('core/string')->substr($conditionName, 1, strpos($conditionName, '/')-1);
|
| 188 |
+
// } else {
|
| 189 |
+
// $conditionName = $websiteModel->getConfig('carriers/matrixrate/condition_name');
|
| 190 |
+
// }
|
| 191 |
+
$conditionFullName = Mage::getModel('matrixrate_shipping/carrier_matrixrate')->getCode('condition_name_short', $conditionName);
|
| 192 |
+
if (!empty($csv)) {
|
| 193 |
+
$exceptions = array();
|
| 194 |
+
$csvLines = explode("\n", $csv);
|
| 195 |
+
$csvLine = array_shift($csvLines);
|
| 196 |
+
$csvLine = $this->_getCsvValues($csvLine);
|
| 197 |
+
if (count($csvLine) < 7) {
|
| 198 |
+
$exceptions[0] = Mage::helper('shipping')->__('Invalid Matrix Rates File Format');
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
$countryCodes = array();
|
| 202 |
+
$regionCodes = array();
|
| 203 |
+
foreach ($csvLines as $k=>$csvLine) {
|
| 204 |
+
$csvLine = $this->_getCsvValues($csvLine);
|
| 205 |
+
if (count($csvLine) > 0 && count($csvLine) < 7) {
|
| 206 |
+
$exceptions[0] = Mage::helper('shipping')->__('Invalid Matrix Rates File Format');
|
| 207 |
+
} else {
|
| 208 |
+
$countryCodes[] = $csvLine[0];
|
| 209 |
+
$regionCodes[] = $csvLine[1];
|
| 210 |
+
}
|
| 211 |
+
}
|
| 212 |
+
|
| 213 |
+
if (empty($exceptions)) {
|
| 214 |
+
$data = array();
|
| 215 |
+
$countryCodesToIds = array();
|
| 216 |
+
$regionCodesToIds = array();
|
| 217 |
+
$countryCodesIso2 = array();
|
| 218 |
+
|
| 219 |
+
$countryCollection = Mage::getResourceModel('directory/country_collection')->addCountryCodeFilter($countryCodes)->load();
|
| 220 |
+
foreach ($countryCollection->getItems() as $country) {
|
| 221 |
+
$countryCodesToIds[$country->getData('iso3_code')] = $country->getData('country_id');
|
| 222 |
+
$countryCodesToIds[$country->getData('iso2_code')] = $country->getData('country_id');
|
| 223 |
+
$countryCodesIso2[] = $country->getData('iso2_code');
|
| 224 |
+
}
|
| 225 |
+
|
| 226 |
+
$regionCollection = Mage::getResourceModel('directory/region_collection')
|
| 227 |
+
->addRegionCodeFilter($regionCodes)
|
| 228 |
+
->addCountryFilter($countryCodesIso2)
|
| 229 |
+
->load();
|
| 230 |
+
|
| 231 |
+
foreach ($regionCollection->getItems() as $region) {
|
| 232 |
+
$regionCodesToIds[$countryCodesToIds[$region->getData('country_id')]][$region->getData('code')] = $region->getData('region_id');
|
| 233 |
+
}
|
| 234 |
+
|
| 235 |
+
foreach ($csvLines as $k=>$csvLine) {
|
| 236 |
+
$csvLine = $this->_getCsvValues($csvLine);
|
| 237 |
+
|
| 238 |
+
if (empty($countryCodesToIds) || !array_key_exists($csvLine[0], $countryCodesToIds)) {
|
| 239 |
+
$countryId = '0';
|
| 240 |
+
if ($csvLine[0] != '*' && $csvLine[0] != '') {
|
| 241 |
+
$exceptions[] = Mage::helper('shipping')->__('Invalid Country "%s" in the Row #%s', $csvLine[0], ($k+1));
|
| 242 |
+
}
|
| 243 |
+
} else {
|
| 244 |
+
$countryId = $countryCodesToIds[$csvLine[0]];
|
| 245 |
+
}
|
| 246 |
+
|
| 247 |
+
if (!isset($countryCodesToIds[$csvLine[0]])
|
| 248 |
+
|| !isset($regionCodesToIds[$countryCodesToIds[$csvLine[0]]])
|
| 249 |
+
|| !array_key_exists($csvLine[1], $regionCodesToIds[$countryCodesToIds[$csvLine[0]]])) {
|
| 250 |
+
$regionId = '0';
|
| 251 |
+
if ($csvLine[1] != '*' && $csvLine[1] != '') {
|
| 252 |
+
$exceptions[] = Mage::helper('shipping')->__('Invalid Region/State "%s" in the Row #%s', $csvLine[1], ($k+1));
|
| 253 |
+
}
|
| 254 |
+
} else {
|
| 255 |
+
$regionId = $regionCodesToIds[$countryCodesToIds[$csvLine[0]]][$csvLine[1]];
|
| 256 |
+
}
|
| 257 |
+
|
| 258 |
+
if (count($csvLine)==9) {
|
| 259 |
+
// we are searching for postcodes in ranges & including cities
|
| 260 |
+
if ($csvLine[2] == '*' || $csvLine[2] == '') {
|
| 261 |
+
$city = '';
|
| 262 |
+
} else {
|
| 263 |
+
$city = $csvLine[2];
|
| 264 |
+
}
|
| 265 |
+
|
| 266 |
+
|
| 267 |
+
if ($csvLine[3] == '*' || $csvLine[3] == '') {
|
| 268 |
+
$zip = '';
|
| 269 |
+
} else {
|
| 270 |
+
$zip = $csvLine[3];
|
| 271 |
+
}
|
| 272 |
+
|
| 273 |
+
|
| 274 |
+
if ($csvLine[4] == '*' || $csvLine[4] == '') {
|
| 275 |
+
$zip_to = '';
|
| 276 |
+
} else {
|
| 277 |
+
$zip_to = $csvLine[4];
|
| 278 |
+
}
|
| 279 |
+
|
| 280 |
+
|
| 281 |
+
if (!$this->_isPositiveDecimalNumber($csvLine[5]) || $csvLine[5] == '*' || $csvLine[5] == '') {
|
| 282 |
+
$exceptions[] = Mage::helper('shipping')->__('Invalid %s From "%s" in the Row #%s', $conditionFullName, $csvLine[5], ($k+1));
|
| 283 |
+
} else {
|
| 284 |
+
$csvLine[5] = (float)$csvLine[5];
|
| 285 |
+
}
|
| 286 |
+
|
| 287 |
+
if (!$this->_isPositiveDecimalNumber($csvLine[6])) {
|
| 288 |
+
$exceptions[] = Mage::helper('shipping')->__('Invalid %s To "%s" in the Row #%s', $conditionFullName, $csvLine[6], ($k+1));
|
| 289 |
+
} else {
|
| 290 |
+
$csvLine[6] = (float)$csvLine[6];
|
| 291 |
+
}
|
| 292 |
+
|
| 293 |
+
|
| 294 |
+
$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]);
|
| 295 |
+
|
| 296 |
+
}
|
| 297 |
+
else {
|
| 298 |
+
|
| 299 |
+
if ($csvLine[2] == '*' || $csvLine[2] == '') {
|
| 300 |
+
$zip = '';
|
| 301 |
+
} else {
|
| 302 |
+
$zip = $csvLine[2]."%";
|
| 303 |
+
}
|
| 304 |
+
|
| 305 |
+
$city='';
|
| 306 |
+
$zip_to = '';
|
| 307 |
+
|
| 308 |
+
if (!$this->_isPositiveDecimalNumber($csvLine[3]) || $csvLine[3] == '*' || $csvLine[3] == '') {
|
| 309 |
+
$exceptions[] = Mage::helper('shipping')->__('Invalid %s From "%s" in the Row #%s', $conditionFullName, $csvLine[3], ($k+1));
|
| 310 |
+
} else {
|
| 311 |
+
$csvLine[3] = (float)$csvLine[3];
|
| 312 |
+
}
|
| 313 |
+
|
| 314 |
+
if (!$this->_isPositiveDecimalNumber($csvLine[4])) {
|
| 315 |
+
$exceptions[] = Mage::helper('shipping')->__('Invalid %s To "%s" in the Row #%s', $conditionFullName, $csvLine[4], ($k+1));
|
| 316 |
+
} else {
|
| 317 |
+
$csvLine[4] = (float)$csvLine[4];
|
| 318 |
+
}
|
| 319 |
+
$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]);
|
| 320 |
+
}
|
| 321 |
+
|
| 322 |
+
|
| 323 |
+
$dataDetails[] = array('country'=>$csvLine[0], 'region'=>$csvLine[1]);
|
| 324 |
+
|
| 325 |
+
}
|
| 326 |
+
}
|
| 327 |
+
if (empty($exceptions)) {
|
| 328 |
+
$connection = $this->_getWriteAdapter();
|
| 329 |
+
|
| 330 |
+
|
| 331 |
+
$condition = array(
|
| 332 |
+
$connection->quoteInto('website_id = ?', $websiteId),
|
| 333 |
+
$connection->quoteInto('condition_name = ?', $conditionName),
|
| 334 |
+
);
|
| 335 |
+
$connection->delete($table, $condition);
|
| 336 |
+
|
| 337 |
+
foreach($data as $k=>$dataLine) {
|
| 338 |
+
try {
|
| 339 |
+
$connection->insert($table, $dataLine);
|
| 340 |
+
} catch (Exception $e) {
|
| 341 |
+
$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']);
|
| 342 |
+
}
|
| 343 |
+
}
|
| 344 |
+
}
|
| 345 |
+
if (!empty($exceptions)) {
|
| 346 |
+
throw new Exception( "\n" . implode("\n", $exceptions) );
|
| 347 |
+
}
|
| 348 |
+
}
|
| 349 |
+
}
|
| 350 |
+
}
|
| 351 |
+
|
| 352 |
+
private function _getCsvValues($string, $separator=",")
|
| 353 |
+
{
|
| 354 |
+
$elements = explode($separator, trim($string));
|
| 355 |
+
for ($i = 0; $i < count($elements); $i++) {
|
| 356 |
+
$nquotes = substr_count($elements[$i], '"');
|
| 357 |
+
if ($nquotes %2 == 1) {
|
| 358 |
+
for ($j = $i+1; $j < count($elements); $j++) {
|
| 359 |
+
if (substr_count($elements[$j], '"') > 0) {
|
| 360 |
+
// Put the quoted string's pieces back together again
|
| 361 |
+
array_splice($elements, $i, $j-$i+1, implode($separator, array_slice($elements, $i, $j-$i+1)));
|
| 362 |
+
break;
|
| 363 |
+
}
|
| 364 |
+
}
|
| 365 |
+
}
|
| 366 |
+
if ($nquotes > 0) {
|
| 367 |
+
// Remove first and last quotes, then merge pairs of quotes
|
| 368 |
+
$qstr =& $elements[$i];
|
| 369 |
+
$qstr = substr_replace($qstr, '', strpos($qstr, '"'), 1);
|
| 370 |
+
$qstr = substr_replace($qstr, '', strrpos($qstr, '"'), 1);
|
| 371 |
+
$qstr = str_replace('""', '"', $qstr);
|
| 372 |
+
}
|
| 373 |
+
$elements[$i] = trim($elements[$i]);
|
| 374 |
+
}
|
| 375 |
+
return $elements;
|
| 376 |
+
}
|
| 377 |
+
|
| 378 |
+
private function _isPositiveDecimalNumber($n)
|
| 379 |
+
{
|
| 380 |
+
return preg_match ("/^[0-9]+(\.[0-9]*)?$/", $n);
|
| 381 |
+
}
|
| 382 |
+
|
| 383 |
+
}
|
package.xml
CHANGED
|
@@ -1,15 +1,16 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Auctionmaid_Matrxrate</name>
|
| 4 |
-
<version>2.0.
|
| 5 |
<stability>stable</stability>
|
| 6 |
-
<license uri="http://www.opensource.org/licenses/osl-3.0.php
|
| 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:
|
| 11 |
|
| 12 |
-
- multiple table
|
|
|
|
| 13 |
- country, region, city, postcode filtering
|
| 14 |
- partial postcode filtering, including pattern matching
|
| 15 |
- numerical postcode ranges
|
|
@@ -17,9 +18,9 @@
|
|
| 17 |
- collection only option</description>
|
| 18 |
<notes>1 - The export csv option is currently disabled. This is so the extension does not conflict with the existing tablerates. There are no plans to resolve this - if you need to view the data look in phpmyadmin.</notes>
|
| 19 |
<authors><author><name>Karen Baker</name><user>auto-converted</user><email>enquiries@auctionmaid.com</email></author></authors>
|
| 20 |
-
<date>2009-
|
| 21 |
-
<time>
|
| 22 |
-
<contents><target name="magecommunity"><dir name="Auctionmaid"><dir name="Adminhtml"><dir name="Model"><dir name="System"><dir name="Config"><dir name="Backend"><dir name="Shipping"><file name="Matrixrate.php" hash="3845daf2530ea28f4c1c9ef0896e4590"/></dir></dir><dir name="Source"><dir name="Shipping"><file name="Matrixrate.php" hash="bf0ab44901dacc3774a8afab91c08848"/></dir></dir></dir></dir></dir></dir><dir name="docs"><file name="AuctionMaid MatrixRate Shipping Module.pdf" hash="5046ebd65b62a3b66556d8efc8a9976a"/><file name="manual install.sql" hash="b1bf0f9b9597d64777a3704f8064b011"/></dir><dir name="example"><dir name="7-col"><file name="export_all_products.csv" hash="ee76a59cc041f80012dc547febaf5393"/><file name="tablerates - item tofrom.csv" hash="c21b4cbf21aefa5cc590ccd2ff073a04"/><file name="tablerates - price tofrom.csv" hash="834af0aeb1aa98abf91f637015f5e3ba"/><file name="tablerates - weight tofrom.csv" hash="c2d26d1097c6a6b1641353b548437421"/></dir><dir name="9-col"><file name="AusRanges.csv" hash="7884e9c2a15f495ce6a80091c38478b5"/><file name="weight postcode range.csv" hash="8b0f12598742f57a5444bfee16219603"/><file name="weight postcode starts with.csv" hash="b83d1c8f6798a42186a63116fc5575b3"/></dir></dir><dir name="Freeoptionalshipping"><dir name="etc"><file name="config.xml" hash="f450793ee1f015b5ea0d84ec910c3d76"/><file name="system.xml" hash="7f1fb48e01e1299bf449a769084bddbc"/></dir><dir name="Model"><dir name="Carrier"><file name="Freeoptionalshipping.php" hash="
|
| 23 |
<compatible/>
|
| 24 |
<dependencies/>
|
| 25 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Auctionmaid_Matrxrate</name>
|
| 4 |
+
<version>2.0.3</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:
|
| 11 |
|
| 12 |
+
- multiple table rate via csv file
|
| 13 |
+
- filter on #items, weight, or price vs destination
|
| 14 |
- country, region, city, postcode filtering
|
| 15 |
- partial postcode filtering, including pattern matching
|
| 16 |
- numerical postcode ranges
|
| 18 |
- collection only option</description>
|
| 19 |
<notes>1 - The export csv option is currently disabled. This is so the extension does not conflict with the existing tablerates. There are no plans to resolve this - if you need to view the data look in phpmyadmin.</notes>
|
| 20 |
<authors><author><name>Karen Baker</name><user>auto-converted</user><email>enquiries@auctionmaid.com</email></author></authors>
|
| 21 |
+
<date>2009-04-20</date>
|
| 22 |
+
<time>01:11:58</time>
|
| 23 |
+
<contents><target name="magecommunity"><dir name="Auctionmaid"><dir name="Adminhtml"><dir name="Model"><dir name="System"><dir name="Config"><dir name="Backend"><dir name="Shipping"><file name="Matrixrate.php" hash="3845daf2530ea28f4c1c9ef0896e4590"/></dir></dir><dir name="Source"><dir name="Shipping"><file name="Matrixrate.php" hash="bf0ab44901dacc3774a8afab91c08848"/></dir></dir></dir></dir></dir></dir><dir name="docs"><file name="AuctionMaid MatrixRate Shipping Module.pdf" hash="5046ebd65b62a3b66556d8efc8a9976a"/><file name="manual install.sql" hash="b1bf0f9b9597d64777a3704f8064b011"/></dir><dir name="example"><dir name="7-col"><file name="export_all_products.csv" hash="ee76a59cc041f80012dc547febaf5393"/><file name="tablerates - item tofrom.csv" hash="c21b4cbf21aefa5cc590ccd2ff073a04"/><file name="tablerates - price tofrom.csv" hash="834af0aeb1aa98abf91f637015f5e3ba"/><file name="tablerates - weight tofrom.csv" hash="c2d26d1097c6a6b1641353b548437421"/></dir><dir name="9-col"><file name="AusRanges.csv" hash="7884e9c2a15f495ce6a80091c38478b5"/><file name="weight postcode range.csv" hash="8b0f12598742f57a5444bfee16219603"/><file name="weight postcode starts with.csv" hash="b83d1c8f6798a42186a63116fc5575b3"/></dir></dir><dir name="Freeoptionalshipping"><dir name="etc"><file name="config.xml" hash="f450793ee1f015b5ea0d84ec910c3d76"/><file name="system.xml" hash="7f1fb48e01e1299bf449a769084bddbc"/></dir><dir name="Model"><dir name="Carrier"><file name="Freeoptionalshipping.php" hash="68128137adb9732cbcba61b1d8585cbb"/></dir></dir></dir><dir name="Matrixrate"><dir name="etc"><file name="config.xml" hash="2fa5eb007a21cd14c06a51afe267a376"/><file name="system.xml" hash="cf1c8c2b472453da081c12cba74ef4d1"/></dir><dir name="Model"><dir name="Carrier"><file name="Matrixrate.php" hash="627c7cb77f0134a17794d2795bcdb632"/></dir><dir name="Mysql4"><dir name="Carrier"><file name="Matrixrate.php" hash="6093b8a988ea5654d209dcd49171bcd3"/><dir name="Matrixrate"><file name="Collection.php" hash="adf9282dce1467f2d47e68b4ecc49de9"/></dir></dir></dir></dir><dir name="sql"><dir name="matrixrate_setup"><file name="mysql4-install-1.0.5.php" hash="32ea533fd01276e78322ae734446dc93"/><file name="mysql4-install-2.0.0.php" hash="32ea533fd01276e78322ae734446dc93"/><file name="mysql4-install-2.0.1.php" hash="505940c2071753011f03a92a18fe6141"/><file name="mysql4-uninstall-2.0.0.php" hash="7efdd041b23194f1fbb9b0afc657bf1e"/><file name="mysql4-uninstall-2.0.1.php" hash="7efdd041b23194f1fbb9b0afc657bf1e"/><file name="mysql4-upgrade-2.0.0.php" hash="32ea533fd01276e78322ae734446dc93"/><file name="mysql4-upgrade-2.0.1.php" hash="505940c2071753011f03a92a18fe6141"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Auctionmaid_Freeoptionalshipping.xml" hash="a8bceecaca2402682f1713222ce23b4d"/><file name="Auctionmaid_Matrixrate.xml" hash="bde75a0463f7dc40affc8b2ce812ec91"/></dir></target></contents>
|
| 24 |
<compatible/>
|
| 25 |
<dependencies/>
|
| 26 |
</package>
|
