Jump to content


Corporate Sponsors


Latest News: (loading..)

- - - - -

UPS XML Time in Transit


  • You cannot reply to this topic
3 replies to this topic

#1 visionspin

  • Community Member
  • 6 posts
  • Real Name:Louis Hutmire

Posted 31 December 2004, 06:54

Looking at
/catalog/includes/modules/shipping/upsxml.php

I need to make a Time in Transit query to UPS prior to the dimensional calculations, so I can figure how much ice I'll need.

Does the Time in Transit query submit to UPS simultaneously with the other stuff? Or does it submit separately, so I can use the result of the Time in Transit to calculate how much ice I'll need?

Any help appreciated... here's a snipet of the code in question:


        if (DIMENSIONS_SUPPORTED) {
            // sort $productsArray according to ready-to-ship (first) and not-ready-to-ship (last)
            usort($productsArray, ready_to_shipCmp);
            // Use packing algoritm to return the number of boxes we'll ship
            $boxesToShip = $this->packProducts($productsArray);
            // Quote for the number of boxes
            for ($i = 0; $i < count($boxesToShip); $i++) {
                $this->_addItem($boxesToShip[$i]['length'], $boxesToShip[$i]['width'], $boxesToShip[$i]['height'], $boxesToShip[$i]['current_weight']);
                $totalWeight += $boxesToShip[$i]['current_weight'];
            }
        } else {
            // The old method. Let osCommerce tell us how many boxes, plus the weight of each (or total? - might be sw/num boxes)
 	 $this->items_qty = 0; //reset quantities
            for ($i = 0; $i < $shipping_num_boxes; $i++) {
                $this->_addItem (0, 0, 0, $shipping_weight);
            }
        }

// BOF Time In Transit: comment out this section if you don't want/need to have 
// expected delivery dates

        $this->servicesTimeintransit = $this->_upsGetTimeServices();  
        if ($this->logfile) {
            error_log("------------------------------------------\n", 3, $this->logfile);
            error_log("Time in Transit: " . $this->timeintransit . "\n", 3, $this->logfile);
        }

// EOF Time In Transit


#2 Jan Zonjee

  • Team Member
  • 7,001 posts
  • Real Name:Jan Zonjee
  • Gender:Male
  • Location:the Netherlands

Posted 31 December 2004, 09:53

As you suspected correctly the code first does a Time in Transit query and then in a separate query gets the rates/quotes:
// EOF Time In Transit

        $upsQuote = $this->_upsGetQuote();


#3 visionspin

  • Community Member
  • 6 posts
  • Real Name:Louis Hutmire

Posted 31 December 2004, 17:55

Woohoo, thank you JanZ! You've made my day a happy one.

I don't suppose you know off the top of your head what the time in transit query result looks like? Is it just a number representing the number of days?

#4 Jan Zonjee

  • Team Member
  • 7,001 posts
  • Real Name:Jan Zonjee
  • Gender:Male
  • Location:the Netherlands

Posted 31 December 2004, 18:10

If you enable logging you can see the exact response of UPS. This is a typical one I guess (added line breaks myself:

<?xml version="1.0"?><TimeInTransitResponse><Response><TransactionReference>
<CustomerContext>Time in Transit</CustomerContext><XpciVersion>1.0001</XpciVersion>
</TransactionReference><ResponseStatusCode>1
</ResponseStatusCode><ResponseStatusDescription>Success
</ResponseStatusDescription><Error><ErrorSeverity>Warning
</ErrorSeverity><ErrorCode>270035</ErrorCode><ErrorDescription>Please note that the ship date been changed</ErrorDescription></Error>
</Response>
<TransitResponse><PickupDate>2004-12-26
</PickupDate><TransitFrom><AddressArtifactFormat><PoliticalDivision2>N****
</PoliticalDivision2>
<PoliticalDivision1>ME</PoliticalDivision1><Country>UNITED STATES
</Country><CountryCode>US</CountryCode><PostcodePrimaryLow>*****
</PostcodePrimaryLow></AddressArtifactFormat>
</TransitFrom><TransitTo><AddressArtifactFormat><PoliticalDivision2>N***** CITY
</PoliticalDivision2><PoliticalDivision1>NY</PoliticalDivision1><Country>UNITED STATES
</Country><CountryCode>US</CountryCode><PostcodePrimaryLow>10027
</PostcodePrimaryLow></AddressArtifactFormat></TransitTo><ShipmentWeight><UnitOfMeasurement><Code>LBS</Code>
</UnitOfMeasurement><Weight>10.0</Weight></ShipmentWeight><InvoiceLineTotal><CurrencyCode>USD
</CurrencyCode><MonetaryValue>100.00</MonetaryValue>
</InvoiceLineTotal><Disclaimer>Services listed as guaranteed are backed by a money-back guarantee for transportation charges only. UPS guarantees the day of delivery for every ground package you ship to any address within the 48 contiguous states, except for any ground package originating in Alaska or Hawaii. In addition, the guarantee applies to shipments from Puerto Rico to the 48 contiguous states. See Terms and Conditions in the Service Guide for details.
</Disclaimer><ServiceSummary><Service><Code>1DM</Code><Description>UPS Next Day Air Early A.M.</Description></Service><Guaranteed><Code>Y</Code>
</Guaranteed><EstimatedArrival><BusinessTransitDays>1</BusinessTransitDays>
<Time>08:00:00</Time><PickupDate>2004-12-27</PickupDate><Date>2004-12-28
</Date><DayOfWeek>TUE</DayOfWeek></EstimatedArrival>
</ServiceSummary><ServiceSummary><Service><Code>1DA</Code><Description>
UPS Next Day Air</Description></Service><Guaranteed><Code>Y</Code>
</Guaranteed><EstimatedArrival><BusinessTransitDays>1</BusinessTransitDays>
<Time>10:30:00</Time><PickupDate>2004-12-27</PickupDate><Date>2004-12-28
</Date><DayOfWeek>TUE</DayOfWeek></EstimatedArrival></ServiceSummary><ServiceSummary><Service><Code>1DP</Code><Description>UPS Next Day Air Saver</Description></Service><Guaranteed><Code>Y</Code>
</Guaranteed><EstimatedArrival><BusinessTransitDays>1</BusinessTransitDays>
<Time>15:00:00</Time><PickupDate>2004-12-27</PickupDate><Date>2004-12-28
</Date><DayOfWeek>TUE</DayOfWeek></EstimatedArrival>
</ServiceSummary><ServiceSummary><Service><Code>2DM</Code>
<Description>UPS 2nd Day Air A.M.</Description></Service><Guaranteed><Code>Y
</Code></Guaranteed><EstimatedArrival><BusinessTransitDays>2</BusinessTransitDays><Time>12:00:00</Time><PickupDate>2004-12-27</PickupDate><Date>2004-12-29</Date><DayOfWeek>WED</DayOfWeek></EstimatedArrival></ServiceSummary><ServiceSummary><Service><Code>2DA</Code><Description>UPS 2nd Day Air</Description></Service><Guaranteed><Code>Y
</Code></Guaranteed><EstimatedArrival><BusinessTransitDays>2
</BusinessTransitDays><Time>23:00:00</Time><PickupDate>2004-12-27
</PickupDate><Date>2004-12-29</Date><DayOfWeek>WED</DayOfWeek>
</EstimatedArrival></ServiceSummary><ServiceSummary><Service><Code>GND
</Code><Description>UPS Ground</Description></Service><Guaranteed><Code>Y</Code>
</Guaranteed><EstimatedArrival><BusinessTransitDays>2</BusinessTransitDays>
<Time>23:00:00</Time><PickupDate>2004-12-27</PickupDate><Date>2004-12-29
</Date><DayOfWeek>WED</DayOfWeek></EstimatedArrival>
</ServiceSummary><MaximumListSize>35</MaximumListSize></TransitResponse>
</TimeInTransitResponse>