PackstationDhl (optional)
GitHub - magesuite/packstation-dhl
This module provides the possibility to choose a DHL packstation as a delivery method. It adds an additional field to the address: Dhl Customer number
and adds a search field selecting packstation
Â
Installation
This module is optional.
composer require "creativestyle/magesuite-packstation-dhl" ^2.0.0
User guide
4.5. DHL Packstation shipping 2.0
Admin settings
In Stores -> Configuration -> Sales -> Delivery methods
a new tab - Packstation DHL
is available.
Â
The following options can be configured:
Name | Value | Comment |
---|---|---|
Enabled |  Yes/No |  |
Method Name | Â | Â |
Title | Â | Â |
Mode |  Live/Sandbox |  |
API Key | Â | Provide API Key for Location Finder - Unified API. It can be found in your DHL developer account in aplication details under 'Credential' section |
Enable Debug |  Yes/No |  Enable this option to log requests |
Price | Â | Â |
Minimum subtotal for free shipping | Â | Â |
Maximum subtotal | Â | Â |
Maximum weight | Â | Â |
Sort Order | Â | Â |
Type |  None/ Per Order / Per Item | Use system value |
Ship to Applicable Countries |  All Allowed Countries/Specific Countries | Use system value |
Ship to Specific Countries | Â | Â |
Displayed Error Message | Default value: | Â |
Â
Backend
Â
List of Packstations
vendor/creativestyle/magesuite-packstation-dhl/Controller/Packstation/Listing.php:26
class Listing extends \Magento\Framework\App\Action\Action implements \Magento\Framework\App\Action\HttpGetActionInterface
{
public function execute()
{
$zip = (string)$this->getRequest()->getParam(self::FORM_ZIP_FIELD);
.....
$response = $this->getPackstationLocations->execute($zip);
.....
return $resultJson->setData($response);
}
}
Â
Get Packstation Locations
vendor/creativestyle/magesuite-packstation-dhl/Service/GetPackstationLocations.php:31
class GetPackstationLocations
{
public function execute(string $zip):? array
{
.....
try {
$requestData = $this->prepareCallParameter($zip);
$response = $this->dhlApiClient->getPackstationsByAddress($requestData);
return $response[self::API_RESPONSE_LOCATION_FIELD];
}
.....
}
}
Â
Api for Dhl
vendor/creativestyle/magesuite-packstation-dhl/Service/DhlApiClient.php:38
Â
Â
Frontend
Frontend screens
In the checkout delivery method section a new method is displayed:
After DHL packstation is selected the address form is hidden, Dhl Customer number
is shown along with the Select packstation
button.
In the modal, it is possible to enter a postal code and select a pack station.
The address of the packstation is displayed in the shipping step of checkout.
Â
Styling
As the module is optional styling is not provided by default. The following import must be uncommented in a child theme that inherits from theme-creativeshop, in src/entries/checkout.ts
file:
Scripts
magesuite-packstation-dhl/view/frontend/web/js/model/packstations-service.js
magesuite-packstation-dhl/view/frontend/web/js/view/dhl-packstation.js
magesuite-packstation-dhl/view/frontend/web/js/view/packstation-selector.js
are the most important scripts with packstation logic.
Additionally the following mixins are added to Magento checkout scripts: