/**
  * determins the right shipping fee for a shipping method depending on the
  * cart's weight and the country of the customers shipping address
  * 
  * @param int $weight Weight in gramm to get fee for
  *
  * @return SilvercartShippingFee the most convenient shipping fee for this shipping method
  * 
  * @author Roland Lehmann <*****@*****.**>,
  *         Sebastian Diel <*****@*****.**>
  * @since 15.11.2014
  */
 public function getShippingFee($weight = null)
 {
     $fee = false;
     if (is_null($weight)) {
         if (!SilvercartCustomer::currentUser() || !SilvercartCustomer::currentUser()->getCart()) {
             return $fee;
         }
         $weight = SilvercartCustomer::currentUser()->getCart()->getWeightTotal();
     }
     $shippingCountry = $this->getShippingCountry();
     if (is_null($shippingCountry)) {
         $shippingAddress = $this->getShippingAddress();
         if (is_null($shippingAddress) && method_exists(Controller::curr(), 'getShippingAddress')) {
             $shippingAddress = Controller::curr()->getShippingAddress();
             $this->setShippingAddress($shippingAddress);
             SilvercartTools::Log('getShippingFee', 'CAUTION: shipping address was not preset! Fallback to current controller ' . Controller::curr()->class, 'SilvercartShippingMethod');
         }
         if ($shippingAddress instanceof SilvercartAddress) {
             $shippingCountry = $shippingAddress->SilvercartCountry();
             $this->setShippingCountry($shippingCountry);
         }
     }
     if ($shippingCountry instanceof SilvercartCountry) {
         $zones = SilvercartZone::getZonesFor($shippingCountry->ID);
         if ($zones->exists()) {
             $zoneMap = $zones->map('ID', 'ID');
             $zoneIDs = $zoneMap->toArray();
             $zoneIDsAsString = "'" . implode("','", $zoneIDs) . "'";
             $filter = array("SilvercartShippingMethodID" => $this->ID);
             $fees = SilvercartShippingFee::get()->filter($filter)->where(sprintf('("MaximumWeight" >= ' . $weight . ' OR "UnlimitedWeight" = 1) AND "SilvercartZoneID" IN (%s)', $zoneIDsAsString))->sort('PostPricing, PriceAmount');
             if ($fees->exists()) {
                 $fee = $fees->first();
             }
         }
     }
     return $fee;
 }