Skip to content
This repository has been archived by the owner on Oct 30, 2019. It is now read-only.

Commit

Permalink
added country filter
Browse files Browse the repository at this point in the history
  • Loading branch information
bastianccm committed Mar 26, 2012
1 parent fb30007 commit 9eaf406
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
17 changes: 14 additions & 3 deletions README.md
Expand Up @@ -10,18 +10,29 @@ Very useful for 'pickup-at-store' or if you need a few self-specified fixed rate
Tested on 1.6.1.0 (should work on Magento >= 1.4)

Questions?
---------
----------
I like feedback and comments, so feel free to write some, as well as bug reports and issues ;-)
b-ike@b-ike.de
http://twitter.com/b_ike


Screenshots
----------
-----------
- Frontend: http://thebod.de/shippingrates1.png
- Backend: http://thebod.de/shippingrates2.png
- Backend filters: http://thebod.de/shippingrates3.png

License
-------
Licensed under http://creativecommons.org/licenses/by/3.0/ CC-BY 3.0, so feel free to use it anywhere.
Licensed under http://creativecommons.org/licenses/by/3.0/ CC-BY 3.0, so feel free to use it anywhere.

Changelog
---------
1.0.3:
- Added country filter

1.0.2:
- Bugfixes

1.0.0:
- First Version
Expand Up @@ -48,7 +48,7 @@ function shippingconfig_filter_show(btn) {
filter_btn = btn;
$(\'shippingconfig_filter_name\').update($(btn).up(1).down(\'.name\').value);
if($(btn).up(1).down(\'.filter\').value == \'\') {
$(btn).up(1).down(\'.filter\').value = \'min_qty:;max_qty:;min_subtotal:;max_subtotal:;min_weight:;max_weight:;\';
$(btn).up(1).down(\'.filter\').value = \'min_qty:;max_qty:;min_subtotal:;max_subtotal:;min_weight:;max_weight:;countries:;\';
}
filter = $(btn).up(1).down(\'.filter\').value.split(\';\').each(function(e,i) {
Expand All @@ -70,6 +70,7 @@ function shippingconfig_filter_hide() {
filter += \'max_subtotal:\' + $(\'shippingconfig_filter_max_subtotal\').value + \';\';
filter += \'min_weight:\' + $(\'shippingconfig_filter_min_weight\').value + \';\';
filter += \'max_weight:\' + $(\'shippingconfig_filter_max_weight\').value + \';\';
filter += \'countries:\' + $(\'shippingconfig_filter_countries\').value + \';\';
$(btn).up(1).down(\'.filter\').value = filter;
Expand All @@ -92,6 +93,9 @@ function shippingconfig_filter_hide() {
<td>' . $this->__('min. weight:') . '</td><td><input class="input-text" style="width: 100px;" id="shippingconfig_filter_min_weight"/></td>
<td>' . $this->__('max. weight:') . '</td><td><input class="input-text" style="width: 100px;" id="shippingconfig_filter_max_weight"/></td>
</tr>
<tr>
<td colspan="2">' . $this->__('limit to countries: (2-characters, comma-separated, e.g. "DE" or "DE,AT,CH")') . '</td><td colspan="2"><input class="input-text" style="width: 100px;" id="shippingconfig_filter_countries"/></td>
</tr>
</table>
<div style="text-align: right;">
<button onclick="shippingconfig_filter_hide()" type="button">' . $this->__('save filter') . '</button>
Expand Down
11 changes: 11 additions & 0 deletions src/app/code/community/Thebod/Shippingrates/Model/Carrier.php
Expand Up @@ -106,6 +106,17 @@ public function checkRate(array $rate, Mage_Shipping_Model_Rate_Request $request
$passed = false;
}
break;

case 'countries':
$dest = strtolower($request->getDestCountryId());
$allowed = explode(',', strtolower($value));
foreach($allowed as $k => $v) {
$allowed[$k] = trim($v);
}
if(!in_array($dest, $allowed) && count($allowed)) {
$passed = false;
}
break;
}
}

Expand Down

0 comments on commit 9eaf406

Please sign in to comment.