In our previous post explained how to create Fedex shipping label using PHP programming language. In this post we explain fedex multiple package shipment label process. By default Fedex allow maximum 150 pound weight limit for one box shipment. If your order exceed shipment weight limit, than Fedex divide package weight as limit wise.
Generate Fedex Multiple Package Shipment Label
In this case one Master Tracking label id is creating for first package, you need to send this master tracking id to child package for create label for each package. You can also check our previous Fedex shipping label code post for single package. Lets check the below PHP code to create Fedex multiple package labels.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 |
<?php $path_to_wsdl = "./ShipService_v19.wsdl"; define('SHIP_MASTERLABEL', 'shipmasterlabel.pdf'); define('SHIP_CHILDLABEL_1', 'shipchildlabel_1.pdf'); define('SHIP_CODMASTERLABEL', 'CODmasterlabel.pdf'); define('SHIP_CODCHILDLABEL_1', 'CODchildlabel_1.pdf'); ini_set("soap.wsdl_cache_enabled", "0"); $client = new SoapClient($path_to_wsdl, array('trace' => 1)); $masterRequest['WebAuthenticationDetail'] = array( 'ParentCredential' => array( 'Key' => 'Paste Your API Key Here', 'Password' => 'Paste Your Password Here' ) ); $masterRequest['ClientDetail'] = array( 'AccountNumber' => '51*****5', 'MeterNumber' => '1******8' ); $masterRequest['TransactionDetail'] = array('CustomerTransactionId' => '*** Ground Domestic MPS Shipping Request - Master using PHP ***'); $masterRequest['Version'] = array( 'ServiceId' => 'ship', 'Major' => '19', 'Intermediate' => '0', 'Minor' => '0' ); $masterRequest['RequestedShipment'] = array( 'ShipTimestamp' => date('c'), 'DropoffType' => 'BUSINESS_SERVICE_CENTER', 'ServiceType' => 'GROUND_HOME_DELIVERY', 'PackagingType' => 'YOUR_PACKAGING', 'Shipper' => array( 'Contact' => array( 'PersonName' => 'Sender Name', 'CompanyName' => 'example.com', 'PhoneNumber' => '800-0987-6489' ), 'Address' => array( 'StreetLines' => array('1300 Basswood Road'), 'City' => 'Austin', 'StateOrProvinceCode' => 'TX', 'PostalCode' => '73301', 'CountryCode' => 'US' ) ), 'Recipient' => array( 'Contact' => array( 'PersonName' => 'Recipient Name', 'CompanyName' => 'example', 'PhoneNumber' => '1234567890' ), 'Address' => array( 'StreetLines' => array('32 wall street albany'), 'City' => 'Herndon', 'StateOrProvinceCode' => 'VA', 'PostalCode' => '20171', 'CountryCode' => 'US', 'Residential' => true ) ), 'LabelSpecification' => array( 'LabelFormatType' => 'COMMON2D', 'ImageType' => 'PDF', 'LabelStockType' => 'PAPER_7X4.75', ), 'PackageCount' => 2, 'RateRequestTypes' => 'LIST', 'RequestedPackageLineItems' => array( '0' => array( 'SequenceNumber'=>1, 'GroupPackageCount'=>1, 'InsuredValue' => array( 'Amount' => 100.00, 'Currency' => 'USD' ), 'Weight' => array( 'Value' => 70.0, 'Units' => 'LB' ), 'Dimensions' => array( 'Length' => 20, 'Width' => 10, 'Height' => 10, 'Units' => 'IN' ), 'CustomerReferences' => array( '0' => array( 'CustomerReferenceType' => 'CUSTOMER_REFERENCE', 'Value' => 'GR4567892' ), '1' => array( 'CustomerReferenceType' => 'INVOICE_NUMBER', 'Value' => 'INV4567892' ), '2' => array( 'CustomerReferenceType' => 'P_O_NUMBER', 'Value' => 'PO4567892' ) ) ) ); $masterResponse = $client->processShipment($masterRequest); $fp = fopen(SHIP_CODMASTERLABEL, 'wb'); fwrite($fp, $masterResponse->CompletedShipmentDetail->CompletedPackageDetails->CodReturnDetail->Label->Parts->Image); fclose($fp); echo '<a href="./'.SHIP_CODMASTERLABEL.'">'.SHIP_CODMASTERLABEL.'</a> was generated.'.Newline; $fp = fopen(SHIP_MASTERLABEL, 'wb'); fwrite($fp, ($masterResponse->CompletedShipmentDetail->CompletedPackageDetails->Label->Parts->Image)); fclose($fp); echo '<a href="./'.SHIP_MASTERLABEL.'">'.SHIP_MASTERLABEL.'</a> was generated. Processing package# 1 ...'; echo "<br>"; // child label request $childRequest['WebAuthenticationDetail'] = array( 'ParentCredential' => array( 'Key' => 'Paste Your API Key Here', 'Password' => 'Paste Your Password Here' ) ); $childRequest['ClientDetail'] = array( 'AccountNumber' => '51******85', 'MeterNumber' => '11*****08' ); $childRequest['TransactionDetail'] = array('CustomerTransactionId' => '*** Ground Domestic MPS Shipping Request - Child using PHP ***'); $childRequest['Version'] = array( 'ServiceId' => 'ship', 'Major' => '19', 'Intermediate' => '0', 'Minor' => '0' ); $childRequest['RequestedShipment'] = array( 'ShipTimestamp' => date('c'), 'DropoffType' => 'DROP_BOX', 'ServiceType' => 'FEDEX_GROUND', // valid values STANDARD_OVERNIGHT, PRIORITY_OVERNIGHT, FEDEX_GROUND, ... 'PackagingType' => 'YOUR_PACKAGING', // valid values FEDEX_BOX, FEDEX_PAK, FEDEX_TUBE, YOUR_PACKAGING, ... 'Shipper' => array( 'Contact' => array( 'PersonName' => 'Sender Name', 'CompanyName' => 'example.com', 'PhoneNumber' => '800-0987-6489' ), 'Address' => array( 'StreetLines' => array('1300 Basswood Road'), 'City' => 'Austin', 'StateOrProvinceCode' => 'TX', 'PostalCode' => '73301', 'CountryCode' => 'US' ) ), 'Recipient' => array( 'Contact' => array( 'PersonName' => 'Recipient Name', 'CompanyName' => 'example', 'PhoneNumber' => '1234567890' ), 'Address' => array( 'StreetLines' => array('32 wall street albany'), 'City' => 'Herndon', 'StateOrProvinceCode' => 'VA', 'PostalCode' => '20171', 'CountryCode' => 'US', 'Residential' => true ) ), 'LabelSpecification' => array( 'LabelFormatType' => 'COMMON2D', // valid values COMMON2D, LABEL_DATA_ONLY 'ImageType' => 'PDF', // valid values DPL, EPL2, PDF, ZPLII and PNG 'LabelStockType' => 'PAPER_7X4.75', ), 'MasterTrackingId' => $masterResponse->CompletedShipmentDetail->MasterTrackingId, 'RateRequestTypes' => 'LIST', // valid values ACCOUNT and LIST 'PackageCount' => 2, 'RequestedPackageLineItems' => array( '0' => array( 'SequenceNumber'=>2, 'GroupPackageCount'=>1, 'InsuredValue' => array( 'Amount' => 75.00, 'Currency' => 'USD' ), 'Weight' => array( 'Value' => 15.0, 'Units' => 'LB' ), 'Dimensions' => array( 'Length' => 15, 'Width' => 10, 'Height' => 10, 'Units' => 'IN' ), 'CustomerReferences' => array( '0' => array( 'CustomerReferenceType' => 'CUSTOMER_REFERENCE', 'Value' => 'GR4567892' ), '1' => array( 'CustomerReferenceType' => 'INVOICE_NUMBER', 'Value' => 'INV4567892' ), '2' => array( 'CustomerReferenceType' => 'P_O_NUMBER', 'Value' => 'PO4567892' ) ) ) ) ); $childResponse = $client->processShipment($childRequest); $child_tracking_number = $childResponse->CompletedShipmentDetail->CompletedPackageDetails->TrackingIds- >TrackingNumber; $fp = fopen(SHIP_CODCHILDLABEL_1, 'wb'); fwrite($fp, $childResponse->CompletedShipmentDetail->CompletedPackageDetails->CodReturnDetail->Label->Parts->Image); fclose($fp); echo '<a href="./'.SHIP_CODCHILDLABEL_1.'">'.SHIP_CODCHILDLABEL_1.'</a> was generated.'.Newline; $fp = fopen(SHIP_CHILDLABEL_1, 'wb'); fwrite($fp, ($childResponse->CompletedShipmentDetail->CompletedPackageDetails->Label->Parts->Image)); fclose($fp); echo '<a href="./'.SHIP_CHILDLABEL_1.'">'.SHIP_CHILDLABEL_1.'</a> was generated'; $imagick = new Imagick(); $imagick->readImage('./shipchildlabel_1.pdf'); // set label path here $imagick->writeImages('converted.jpg', false); ?> |
As you see in above code, first master package label is created and pass master tracking id to child package api request. Using this way you can create Fedex Label for Multiple Package Shipments.
Greetings of the Day,
Hi, we are using FedEX services with SOAP API for creating the shipping label, but we want to switch with Rest API, if you have the documentation in Rest API, Could you share the documentation with me?
Please share on [email protected]
I don’t think so, that FedEx support rest API for creating shipping label.
Okay, Thank you.