Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /* UPS CODES
- UPS Next Day Air | 1DA |Miva: 1DA
- UPS Next Day Air Saver | 1DP
- UPS 2nd Day Air A.M. | 2DM
- UPS 2nd Day Air | 2DA |Miva: 02
- UPS 3 Day Select | 3DS |Miva: 12
- UPS GROUND | GND |Miva: 03
- */
- $toCity = $_REQUEST['toCity'];
- $toState = $_REQUEST['toState'];
- $toZip = $_REQUEST['toZip'];
- $toCountry = $_REQUEST['toCountry'];
- $packageWeight = $_REQUEST['packageWeight'];
- // You can add changes in here.. For instance if it's after 4pm, ship the next day?
- $nextTuesday = strtotime("next Tuesday");
- $today = date('Ymd', $nextTuesday);
- //$today = date('Ymd');
- ?>
- <?php
- require("upsEstimate.php");
- include_once("miva-array.php");
- /*************************************
- Get your own credentials from ups.com
- *************************************/
- $ups_accessnumber = "YOUR ACCESS NUMBER";
- $ups_username = "YOUR USERNAME";
- $ups_password = "YOUR PASSWORD";
- $ups_shippernumber = ""; // This can be empty.
- // All UPS Services you want
- $services = array(
- "03"=>"GND",
- "12"=>"3DS",
- "02"=>"2DA",
- "01"=>"1DA"
- );
- $myRate = new upsEstimate;
- $myRate->setCredentials($ups_accessnumber, $ups_username, $ups_password, $ups_shippernumber);
- $rate = $myRate->getRate($toCity, $toState, $toZip, $toCountry, $packageWeight, $today);
- $estimates = $rate['TransitResponse']['ServiceSummary'];
- $mivaArray = [];
- foreach ( $services as $name => $code) {
- foreach ( $estimates as $r ) {
- if ( $r['Service']['Code'] == $code ) {
- $time = strtotime($r['EstimatedArrival']['Date']);
- $date = date('l, F d, Y', $time);
- $mivaArray[] = array('module' => 'upsxml', 'code' => $name, 'estimate' => $date);
- }
- }
- }
- echo MivaArraySerializer::serialize($mivaArray);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement