简体   繁体   中英

FedEx API using PHP and Saturday Shipping

I am trying to figure out how to force a Saturday delivery using the fedex api with php. Can anyone help with a working example. I have tried several ways with a Friday ship date and none of them give a Saturday delivery, only a Monday delivery. Here is a portion of the code :

            if ($data['special_service']) {
                 echo "special services friday ship date <br>";

                 //$request['SpecialServicesRequested']['SpecialServiceTypes'] = 'SATURDAY_DELIVERY';
                 //$request['RateRequest']['VariableOptionsServiceOptionType'] = 'SATURDAY_DELIVERY';
                 $request['SpecialServicesRequested']['ShipmentSpecialServiceType'] = 'SATURDAY_DELIVERY';

            }
            $request['ReturnTransitAndCommit'] = true;
            $request['RequestedShipment']['DropoffType'] = 'REGULAR_PICKUP'; // valid values REGULAR_PICKUP, REQUEST_COURIER, ...
            $request['RequestedShipment']['ShipTimestamp'] = $date; // date("c", $post[3])
            $request['RequestedShipment']['ServiceType'] = $data['service_type']; // valid values STANDARD_OVERNIGHT, PRIORITY_OVERNIGHT, FEDEX_GROUND, ...
            $request['RequestedShipment']['PackagingType'] = 'FEDEX_ENVELOPE'; // valid values FEDEX_BOX, FEDEX_PAK, FEDEX_TUBE, YOUR_PACKAGING, ...
            $request['RequestedShipment']['TotalInsuredValue']=array(
                    'Amount'=>100,
                    'Currency'=>'USD'
            );
            $request['RequestedShipment']['Shipper'] = $this->addShipper();
            $request['RequestedShipment']['Recipient'] = $this->addRecipient($data);
            $request['RequestedShipment']['ShippingChargesPayment'] = $this->addShippingChargesPayment();
            $request['RequestedShipment']['PackageCount'] = '1';
            $request['RequestedShipment']['RequestedPackageLineItems'] = $this->addPackageLineItem1();

This is the result I get from the code :

array(3) { ["amount"]=> string(5) "33.53" ["deliveryDate"]=> string(10) "12/07/2015" ["serviceType"]=> string(18) "PRIORITY_OVERNIGHT" }

The date returned is a Monday and the Saturday shipping charge has not been added.

Finally got something that worked :

$request['RequestedShipment']['SpecialServicesRequested']['SpecialServiceTypes'] = 'SATURDAY_DELIVERY';

Now it returns what I'm expecting : array(3) { ["amount"]=> string(5) "50.01" ["deliveryDate"]=> string(10) "12/05/2015" ["serviceType"]=> string(18) "PRIORITY_OVERNIGHT" }

Using the 'SpecialServicesRequested' option results in only Saturday delivery options being returned. If you instead use 'VariableOptions' then you will get Saturday delivery options intermixed with the standard ones. Example:

$ratesRequest['VariableOptions'] = 'SATURDAY_DELIVERY';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM