|
| 1 | +Create Label From Shipment Details |
| 2 | +====================================== |
| 3 | +[ShipEngine](www.shipengine.com) allows you programmatically create shipping labels. Please see [our docs](https://www.shipengine.com/docs/labels/create-a-label/) to learn more about creating shipping labels. |
| 4 | + |
| 5 | +Input Parameters |
| 6 | +------------------------------------- |
| 7 | +The `createLabelFromShipmentDetails` method accepts shipment related params as seen in the documentation above. |
| 8 | + |
| 9 | +Output |
| 10 | +-------------------------------- |
| 11 | +The `createLabelFromShipmentDetails` method returns the label that was created. |
| 12 | + |
| 13 | +Example |
| 14 | +```php |
| 15 | +use ShipEngine\ShipEngine; |
| 16 | +use ShipEngine\Message\ShipEngineException; |
| 17 | + |
| 18 | +function createLabelFromShipmentDetailsDemoFunction() { |
| 19 | + $client = new ShipEngine('API-Key'); |
| 20 | + |
| 21 | + $details = [ |
| 22 | + "shipment" => [ |
| 23 | + "service_code" => "ups_ground", |
| 24 | + "ship_to" => [ |
| 25 | + "name" => "Jane Doe", |
| 26 | + "address_line1" => "525 S Winchester Blvd", |
| 27 | + "city_locality" => "San Jose", |
| 28 | + "state_province" => "CA", |
| 29 | + "postal_code" => "95128", |
| 30 | + "country_code" => "US", |
| 31 | + "address_residential_indicator" => "yes" |
| 32 | + ], |
| 33 | + "ship_from" => [ |
| 34 | + "name" => "John Doe", |
| 35 | + "company_name" => "Example Corp", |
| 36 | + "phone" => "555-555-5555", |
| 37 | + "address_line1" => "4009 Marathon Blvd", |
| 38 | + "city_locality" => "Austin", |
| 39 | + "state_province" => "TX", |
| 40 | + "postal_code" => "78756", |
| 41 | + "country_code" => "US", |
| 42 | + "address_residential_indicator" => "no" |
| 43 | + ], |
| 44 | + "packages" => [ |
| 45 | + [ |
| 46 | + "weight" => [ |
| 47 | + "value" => 20, |
| 48 | + "unit" => "ounce" |
| 49 | + ], |
| 50 | + "dimensions" => [ |
| 51 | + "height" => 6, |
| 52 | + "width" => 12, |
| 53 | + "length" => 24, |
| 54 | + "unit" => "inch" |
| 55 | + ] |
| 56 | + ] |
| 57 | + ] |
| 58 | + ] |
| 59 | + ]; |
| 60 | + |
| 61 | + try { |
| 62 | + print_r($client->createLabelFromShipmentDetails($details)); |
| 63 | + } catch (ShipEngineException $e) { |
| 64 | + print_r($e -> getMessage()); |
| 65 | + } |
| 66 | +} |
| 67 | + |
| 68 | +createLabelFromShipmentDetailsDemoFunction(); |
| 69 | + |
| 70 | +``` |
| 71 | + |
| 72 | +Example Output |
| 73 | +----------------------------------------------------- |
| 74 | + |
| 75 | +### Array of connected carrier accounts |
| 76 | +```php |
| 77 | +Array |
| 78 | +( |
| 79 | + [label_id] => se-75449505 |
| 80 | + [status] => completed |
| 81 | + [shipment_id] => se-144329069 |
| 82 | + [ship_date] => 2021-08-04T00:00:00Z |
| 83 | + [created_at] => 2021-08-04T15:40:26.7329234Z |
| 84 | + [shipment_cost] => Array |
| 85 | + ( |
| 86 | + [currency] => usd |
| 87 | + [amount] => 27.98 |
| 88 | + ) |
| 89 | + |
| 90 | + [insurance_cost] => Array |
| 91 | + ( |
| 92 | + [currency] => usd |
| 93 | + [amount] => 0 |
| 94 | + ) |
| 95 | + |
| 96 | + [tracking_number] => 1Z63R0960328699118 |
| 97 | + [is_return_label] => |
| 98 | + [rma_number] => |
| 99 | + [is_international] => |
| 100 | + [batch_id] => |
| 101 | + [carrier_id] => se-423888 |
| 102 | + [service_code] => ups_ground |
| 103 | + [package_code] => package |
| 104 | + [voided] => |
| 105 | + [voided_at] => |
| 106 | + [label_format] => pdf |
| 107 | + [display_scheme] => label |
| 108 | + [label_layout] => 4x6 |
| 109 | + [trackable] => 1 |
| 110 | + [label_image_id] => |
| 111 | + [carrier_code] => ups |
| 112 | + [tracking_status] => in_transit |
| 113 | + [label_download] => Array |
| 114 | + ( |
| 115 | + [pdf] => https://api.shipengine.com/v1/downloads/10/VF_Xyq2J002-GxtKSn_Plw/label-75449505.pdf |
| 116 | + [png] => https://api.shipengine.com/v1/downloads/10/VF_Xyq2J002-GxtKSn_Plw/label-75449505.png |
| 117 | + [zpl] => https://api.shipengine.com/v1/downloads/10/VF_Xyq2J002-GxtKSn_Plw/label-75449505.zpl |
| 118 | + [href] => https://api.shipengine.com/v1/downloads/10/VF_Xyq2J002-GxtKSn_Plw/label-75449505.pdf |
| 119 | + ) |
| 120 | + |
| 121 | + [form_download] => |
| 122 | + [insurance_claim] => |
| 123 | + [packages] => Array |
| 124 | + ( |
| 125 | + [0] => Array |
| 126 | + ( |
| 127 | + [package_id] => 80068779 |
| 128 | + [package_code] => package |
| 129 | + [weight] => Array |
| 130 | + ( |
| 131 | + [value] => 20 |
| 132 | + [unit] => ounce |
| 133 | + ) |
| 134 | + |
| 135 | + [dimensions] => Array |
| 136 | + ( |
| 137 | + [unit] => inch |
| 138 | + [length] => 24 |
| 139 | + [width] => 12 |
| 140 | + [height] => 6 |
| 141 | + ) |
| 142 | + |
| 143 | + [insured_value] => Array |
| 144 | + ( |
| 145 | + [currency] => usd |
| 146 | + [amount] => 0 |
| 147 | + ) |
| 148 | + |
| 149 | + [tracking_number] => 1Z63R0960328699118 |
| 150 | + [label_messages] => Array |
| 151 | + ( |
| 152 | + [reference1] => |
| 153 | + [reference2] => |
| 154 | + [reference3] => |
| 155 | + ) |
| 156 | + |
| 157 | + [external_package_id] => |
| 158 | + [sequence] => 1 |
| 159 | + ) |
| 160 | + |
| 161 | + ) |
| 162 | + |
| 163 | + [charge_event] => carrier_default |
| 164 | +) |
| 165 | +``` |
0 commit comments