- Shipment wizard
- SEND SHIPMENT TO DHL SERVERS
We provide shipment wizard. This is the best way to create shipment.
First, we have to init wizard by facade method:
$wizard = \xGrz\Dhl24\Facades\DHL24::wizard();
All wizard methods are chainable.
You can automate shipper data fill by creating middle class that fill all shipper data. By design, you should fill shipper data manually for each shipment.
$wizard
->shipperName('ACME Corp Ltd.')
->shipperPostalCode('02-777')
->shipperCity('Otwock')
->shipperStreet('Warszawska')
->shipperHouseNumber('102/20')
->shipperContactPerson('John Rambo')
->shipperContactEmail('[email protected]')
->shipperContactPhone('504094400');
setting
shipperContact*
is optional.
$wizard
->receiverName('Microsoft Corp Ltd.')
->receiverPostalCode('03888', 'DE')
->receiverCity('Lomza')
->receiverStreet('Gdańska')
->receiverHouseNumber('101/1')
->receiverContactPerson('Johnny Travolta')
->receiverContactEmail('[email protected]')
->receiverContactPhone('677987787');
When setting postal code you can optionally pass second parameter with receiver country code ('DE' in example). This parameter is optional for shipments delivered in Poland. Package will set default 'PL' as receiver country.
There are predefined shipments type like ENVELOPE
, PACKAGE
or PALLET
.
We are storing shipment item type in xGrz\Dhl24\Enums\DHLShipmentItemType::class
.
ENVELOPE
item type requires onlyquantity
parameter, however:PACKAGE
andPALETTE
item type requires more details about item likeweight
, diamentions ornonStandard
.
$wizard
->addItem(\xGrz\Dhl24\Enums\DHLShipmentItemType::ENVELOPE, $quantity)
->addItem(\xGrz\Dhl24\Enums\DHLShipmentItemType::PACKAGE, $quantity, $weight, $width, $height, $length, $nonStandard)
First parameter is always item type as enum mentioned above.
quantity
- (integer) quantity of itemsweight
- (integer|float) weight of itemwidth
,height
,length
- (integer) diamentions in centimetersnonStandard
- (bool) optional (default: false)
DHL requires shipment content description. No default content is set. Read about our content manager (helper) here.
$wizard->content('Electronics');
Shipment type defines which DHL product you would like to use. For now, you can set one of:
- DOMESTIC (standard DHL shipment),
- DOMESTIC09 (delivery to 9:00am next business day),
- DOMESTIC12 (delivery to 12:00am NBD)
- PREMIUM (DHL guarantee NBD delivery)
- EVENING_DELIVERY (delivery in evening)
We do not provide foreign countries delivery right now. This will be added in the future.
$wizard->shipmentType(xGrz\Dhl24\Enums\DHLDomesticShipmentType::DOMESTIC);
By default, wizard will assume DOMESTIC (standard shipment).
Set shipping date.
$wizard->shipmentDate(Carbon $date)
As a date
parameter please provide carbon object. We took only date from this object, so you don't have to set any
hours.
If you want to provide shipment value (for insurance purposes) just add value to wizard:
$wizard->shipmentValue(int|float 2000);
By the law regulations, all shipments (without collect on delivery) are insured up to 500PLN without charging you.
In that case we provided intelligent cost saver. It can be configured in dhl24.php
file.
If you set intelligent_cost_saver
to false
insurance charge will be taken even if shipment value is below 500PLN.
Maximum cost saver value is configurable too.
Intelligent cost saver is not applied when you set collect on delivery (COD). Insurance value will be set to collect on delivery value automatically. If you pass higher shipment value (in compare with COD) higher value will be set as insurance.
$wizard->collectOnDelivery(2500, 'INV F/102/2010');
amount
(required) should be integer or float.reference
(optional string) you can pass COD reference for ex. invoice number.
If you pass reference to your COD it will be copied to shipment reference (if not set earlier).
If COD amount is higher than shipment value, shipment value will be overwritten by COD value.
You can pass reference to shipment. It will be shown on label. This reference is not COD reference equal. You can pass here for example order number.
$wizard->reference('ORDER 111');
When you passed COD without reference shipment reference text will be applied as COD reference too.
Please read cost center docs witch describes this feature.
$wizard->costCenter(DHLCostCenter);
Please pass DHLCostCenter
model as a parameter.
You can add comment (visible on label) to shipment
$wizard->comment('Please call customer before delivery');
Your package will be waiting in terminal for pickup by customer
$wizard->selfCollect();
$wizard->returnOnDelivery(string $rod_reference);
$wizard->proofOfDelviery();
$wizard->preDeliveryInformation();
$wizard->preAviso();
$wizard->saturdayPickup();
$wizard->saturdayDelivery();
At this point shipment is not stored in local database.
It is automatically stored when you send shipment to API without errors (DHL24Excetion);
$shipmentNumber = $wizard->create();
When shipment is accepted by API DHLShipment will be stored in database with shipment number assigned by API. Event ShipmentCreatedEvent is dispatched. One of listeners of ShipmentCreatedEvent is GetShipmentLabelListener. It will download label in the background.
As a result of
create
method shipment number will be returned.