Пример #1
0
 * Include the configuration file
 */
require_once dirname(__FILE__) . '/../inc/config.php';
$pickup_codes = array('01' => 'Daily Pickup', '03' => 'Customer Counter', '06' => 'One Time Pickup', '07' => 'On Call Air', '11' => 'Suggested Retail Rates', '19' => 'Letter Center', '20' => 'Air Service Center');
// end $pickup_codes
// check if the form was submitted
if (!empty($_POST['submit'])) {
    $shipment = array('pickup_type' => array('code' => $_POST['pickup_type'], 'description' => $pickup_codes[$_POST['pickup_type']]), 'service' => $_POST['service'], 'packages' => array(array('packaging' => array('code' => 21, 'description' => 'Express Box'), 'description' => 'Package from customer', 'units' => 'LBS', 'weight' => 100.0), array('packaging' => array('code' => '02', 'description' => 'Package'), 'description' => 'Package from customer', 'units' => 'LBS', 'weight' => 23.6)), 'saturday' => array('pickup' => true, 'deliver' => false), 'pickup_day' => '02', 'scheduling_method' => '02');
    // end $shipment
    $shipper = array('name' => 'Shipper Name', 'phone' => '1234567890', 'number' => null, 'street' => 'Address Line1', 'street2' => 'Address Line2', 'city' => 'West Chester', 'state' => 'PA', 'zip' => '19380', 'country' => 'US');
    // end $shipper
    $ship_from = array('name' => 'Ship F. Name', 'phone' => '1234567890', 'street' => 'Address Line1', 'street2' => 'Address Line2', 'street3' => 'Address Line3', 'city' => 'Carlisle', 'state' => 'PA', 'zip' => '17013', 'country' => 'US');
    // end $ship_from
    $destination = array('name' => 'Recipients Name', 'phone' => '1234567890', 'street' => 'Address Line', 'city' => 'Duncannon', 'state' => 'PA', 'zip' => '17020', 'country' => 'US');
    // end $destination
    $rate = new UpsAPI_RatesAndService($shipment, $shipper, $ship_from, $destination);
    $xml = $rate->buildRequest();
    // check the output type
    if ($_POST['output'] == 'array') {
        $response = $rate->sendRequest($xml, false);
        echo 'Response Output:<br />';
        var_dump($response);
    } else {
        $response = $rate->sendRequest($xml, true);
        echo 'Response Output:<br />';
        echo '<pre>' . htmlentities($response) . '</pre>';
    }
    // end else the output type is XML
    var_dump($rate->isError());
    var_dump($rate->getError());
    var_dump($rate->getWarnings());
Пример #2
0
 public static function package($weight, $code = "02", $desc = "Package from customer", $units = "LBS")
 {
     return array('packaging' => UpsAPI_RatesAndService::packagingCode($code), 'description' => $desc, 'units' => $units, 'weight' => $weight);
 }