Exemple #1
0
 public function getAllRates()
 {
     $return = new ShippingRateSet();
     if ('US' == $this->destCountry) {
         $services = array_keys((array) $this->getConfigValue('domestic'));
         foreach ($services as $service) {
             $this->setService($service);
             $rates = $this->getRates();
             if ($rates instanceof ShippingRateSet) {
                 $return->merge($rates);
             }
         }
     } else {
         $rates = $this->getRates();
         $services = array_keys((array) $this->getConfigValue('international'));
         if ($rates instanceof ShippingRateSet) {
             foreach ($rates as $rate) {
                 $name = $rate->getServiceName();
                 foreach ($services as $service) {
                     if (substr($name, 0, strlen($service) + 2) == $service . ' (') {
                         $return->add($rate);
                         break;
                     }
                 }
             }
         }
     }
     return $return;
 }
Exemple #2
0
 /**
  *  Returns real time shipping rates for the particular shipment
  *
  *	@return ShippingRateSet
  */
 public function getRealTimeRates(Shipment $shipment)
 {
     $rates = new ShippingRateSet();
     $app = self::getApplication();
     foreach ($app->getEnabledRealTimeShippingServices() as $handler) {
         $rates->merge(ShipmentDeliveryRate::getRealTimeRates($app->getShippingHandler($handler), $shipment));
     }
     return $rates;
 }