Example #1
0
 public function getRates()
 {
     //try {
     //define a package, we could specify the dimensions of the box if we wanted a more accurate estimate
     //$this->setShipper();
     //$shipper = $this->getShipper();
     $shipment = new \SimpleUPS\Rates\Shipment();
     $shipment->setDestination($this->destination);
     foreach ($this->packages as $package) {
         $shipment->addPackage($package);
     }
     //$service = new \SimpleUPS\Service();
     //$service->setCode('03');
     //$shipment->setService($service);
     //$shipment->setShipper($shipper);
     $rates = UPS::getRates($shipment);
     foreach ($rates as $shippingMethod) {
         $this->_rates[$shippingMethod->getService()->getCode()] = $shippingMethod;
     }
     return $this->_rates;
     //} catch (ShipperException $e) {
     //doh, something went wrong
     echo 'Failed: (' . get_class($e) . ') ' . $e->getMessage() . '<br/>';
     echo 'Stack trace:<br/><pre>' . $e->getTraceAsString() . '</pre>';
     //}
     if (UPS::getDebug()) {
         UPS::getDebugOutput();
     }
 }