Advertisement
Guest User

Untitled

a guest
Aug 25th, 2016
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. <?php
  2. /* UPS CODES
  3. UPS Next Day Air | 1DA |Miva: 1DA
  4. UPS Next Day Air Saver | 1DP
  5. UPS 2nd Day Air A.M. | 2DM
  6. UPS 2nd Day Air | 2DA |Miva: 02
  7. UPS 3 Day Select | 3DS |Miva: 12
  8. UPS GROUND | GND |Miva: 03
  9.  
  10. */
  11. $toCity = $_REQUEST['toCity'];
  12. $toState = $_REQUEST['toState'];
  13. $toZip = $_REQUEST['toZip'];
  14. $toCountry = $_REQUEST['toCountry'];
  15. $packageWeight = $_REQUEST['packageWeight'];
  16. // You can add changes in here.. For instance if it's after 4pm, ship the next day?
  17. $nextTuesday = strtotime("next Tuesday");
  18. $today = date('Ymd', $nextTuesday);
  19. //$today = date('Ymd');
  20. ?>
  21. <?php
  22.  
  23. require("upsEstimate.php");
  24. include_once("miva-array.php");
  25. /*************************************
  26. Get your own credentials from ups.com
  27. *************************************/
  28. $ups_accessnumber = "YOUR ACCESS NUMBER";
  29. $ups_username = "YOUR USERNAME";
  30. $ups_password = "YOUR PASSWORD";
  31. $ups_shippernumber = ""; // This can be empty.
  32.  
  33. // All UPS Services you want
  34. $services = array(
  35. "03"=>"GND",
  36. "12"=>"3DS",
  37. "02"=>"2DA",
  38. "01"=>"1DA"
  39. );
  40.  
  41. $myRate = new upsEstimate;
  42. $myRate->setCredentials($ups_accessnumber, $ups_username, $ups_password, $ups_shippernumber);
  43. $rate = $myRate->getRate($toCity, $toState, $toZip, $toCountry, $packageWeight, $today);
  44. $estimates = $rate['TransitResponse']['ServiceSummary'];
  45.  
  46. $mivaArray = [];
  47. foreach ( $services as $name => $code) {
  48. foreach ( $estimates as $r ) {
  49. if ( $r['Service']['Code'] == $code ) {
  50. $time = strtotime($r['EstimatedArrival']['Date']);
  51. $date = date('l, F d, Y', $time);
  52. $mivaArray[] = array('module' => 'upsxml', 'code' => $name, 'estimate' => $date);
  53. }
  54. }
  55. }
  56. echo MivaArraySerializer::serialize($mivaArray);
  57. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement