Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

BUG: made things continue to work when there are no existing Zones.

Changed country codes to full country names.
  • Loading branch information...
commit 2e9dcf4ff338d7c6e936f36f52fc8d77469dd4ed 1 parent 22eb3a8
@jedateach jedateach authored
View
7 README.md
@@ -12,12 +12,13 @@ Visit the 'Shipping' section of the CMS.
Add new zone(s)
For each zone:
- * Optionally specify a country, and region.
- * Specify a number of maximum weights, and associated cost
+ * Optionally specify a country, and region.
+ * Specify a number of maximum weights, and associated cost
Visit the site config section, and choose a default zone.
## Future
* This module may be merged into the core module shop at some stage.
- * Allow setting up different shipping services per zone.
+ * Allow setting up different shipping services per zone.
+ * Fail/fall back when no appropriate zone is set/found
View
4 code/ShippingZone.php
@@ -65,9 +65,9 @@ function getCMSFields(){
}
function getTitle(){
- $country = $this->Country;
+ $country = Geoip::countryCode2name($this->Country);
if(empty($country)){
- $country = "international";
+ $country = _t("ShippingZone.INTERNATIONAL","International");
}
return implode(" - ",array_filter(array($country,$this->Region)));
}
View
9 code/WeightShippingConfig.php
@@ -11,10 +11,11 @@ function extraStatics(){
}
function updateCMSFields($fields){
- $zones = DataObject::get('ShippingZone');
- $fields->addFieldToTab('Root.Shipping',
- $zonesfield = new DropdownField("DefaultShippingZoneID","Default Shipping Zone",$zones->map())
- );
+ if($zones = DataObject::get('ShippingZone')){
+ $fields->addFieldToTab('Root.Shipping',
+ $zonesfield = new DropdownField("DefaultShippingZoneID","Default Shipping Zone",$zones->map())
+ );
+ }
}
}
View
22 code/ZoneWeightShippingModifier.php
@@ -26,13 +26,13 @@ function value($subtotal = null){
}
}
}
- //TODO: prevent free shipping?
-
return $this->Amount = $amount;
}
function TableTitle(){
- return parent::TableTitle()." (".$this->getZone()->getTitle().")";
+ if($zone = $this->getZone())
+ return parent::TableTitle()." (".$zone->getTitle().")";
+ return parent::TableTitle();
}
function getZone(){
@@ -40,7 +40,10 @@ function getZone(){
if(!$zone->exists()){
$zone = SiteConfig::current_site_config()->DefaultShippingZone();
}
- return $zone;
+ if($zone->exists()){
+ return $zone;
+ }
+ return null;
}
}
@@ -48,10 +51,12 @@ function getZone(){
class ChangeZoneForm extends Form{
function __construct($controller) {
- $zones = DataObject::get('ShippingZone');
$fields = new FieldSet(
- $zonesfield = new DropdownField("ZoneID","Shipping Region",$zones->map())
+ $zonesfield = new DropdownField("ZoneID","Shipping Region")
);
+ if($zones = DataObject::get('ShippingZone')){
+ $zonesfield->setSource($zones->map());
+ }
$actions = new FieldSet(
new FormAction('changeZone',"Change Region")
);
@@ -78,7 +83,10 @@ class ChangeZoneFormExtension extends Extension{
);
function ChangeZoneForm(){
- return new ChangeZoneForm($this->owner);
+ if(DataObject::get('ShippingZone')){
+ return new ChangeZoneForm($this->owner);
+ }
+ return null;
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.