Reputation: 41
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.
Upvotes: 2
Views: 1550
Reputation: 41
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';
Upvotes: 4
Reputation: 41
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" }
Upvotes: 2