Exemplo n.º 1
0
 public function testship()
 {
     print_r(get_declared_classes());
     try {
         //set shipper
         $fromAddress = new \SimpleUPS\InstructionalAddress();
         $fromAddress->setAddressee('Mark Stevens');
         $fromAddress->setStreet('10571 Pico Blvd');
         $fromAddress->setStateProvinceCode('CA');
         $fromAddress->setCity('Los Angeles');
         $fromAddress->setPostalCode(90064);
         $fromAddress->setCountryCode('US');
         $shipper = new \SimpleUPS\Shipper();
         $shipper->setNumber('CCE85AD5154DDC46');
         $shipper->setAddress($fromAddress);
         \SimpleUPS\UPS::setShipper($shipper);
         //define a shipping destination
         $shippingDestination = new \SimpleUPS\InstructionalAddress();
         $shippingDestination->setStreet('220 Bowery');
         $shippingDestination->setStateProvinceCode('NY');
         $shippingDestination->setCity('New York');
         $shippingDestination->setPostalCode(10453);
         $shippingDestination->setCountryCode('US');
         //define a package, we could specify the dimensions of the box if we wanted a more accurate estimate
         $package = new \SimpleUPS\Rates\Package();
         $package->setWeight('7');
         $shipment = new \SimpleUPS\Rates\Shipment();
         $shipment->setDestination($shippingDestination);
         $shipment->addPackage($package);
         echo 'Rates: ';
         echo '<ul>';
         foreach (UPS::getRates($shipment) as $shippingMethod) {
             echo '<li>' . $shippingMethod->getService()->getDescription() . ' ($' . $shippingMethod->getTotalCharges() . ')</li>';
         }
         echo '</ul>';
     } catch (Exception $e) {
         //doh, something went wrong
         echo 'Failed: (' . get_class($e) . ') ' . $e->getMessage() . '<br/>';
         echo 'Stack trace:<br/><pre>' . $e->getTraceAsString() . '</pre>';
     }
 }
Exemplo n.º 2
0
 public function setShipper()
 {
     $address = new \SimpleUPS\InstructionalAddress();
     $address->setAddressee(UPS_SHIPPER_ADDRESSEE);
     $address->setAddressline2(UPS_SHIPPER_ADDRESS_LINE2);
     $address->setAddressline3(UPS_SHIPPER_ADDRESS_LINE3);
     $address->setCity(UPS_SHIPPER_CITY);
     $address->setStateProvinceCode(UPS_SHIPPER_STATEPROVINCE_CODE);
     $address->setPostalCode(UPS_SHIPPER_POSTAL_CODE);
     $address->setCountryCode(UPS_SHIPPER_COUNTRY_CODE);
     $shipper = new \SimpleUPS\Shipper();
     $shipper->setAddress($address);
     $shipper->setNumber(UPS_SHIPPER_NUMBER);
     $this->shipper = $shipper;
 }