dhlparcel / plugin-magento2-release

DHL Parcel plugin for Magento 2
Open Software License 3.0
9 stars 21 forks source link

Cannot create shipment when the selected ServicePoint is not one of the 40 ServicePoints closest to the shipping address #10

Closed aadmathijssen closed 4 years ago

aadmathijssen commented 4 years ago

When a customer has placed an order with the dhlparcel_servicepoint shipping method, it is not always possible to create a shipment for such an order from the sales/order/view admin page using the "Ship" button. After clicking this button, the admin/order_shipment/new page that is opened contains a "Create DHL shipping label" checkbox. When this checkbox is enabled (which is the default), details of the DHL shipment can be entered. "Step 2 Delivery method" contains a dropdown that should contain the ServicePoint that the customer has selected, but this is not always the case: in some cases, the dropdown is empty and in other cases, the dropdown only contains different addresses.

The reason for this is that the service point dropdown options are determined by performing a search using the https://api-gw.dhlparcel.nl/parcel-shop-locations/ endpoint for the postal code and country id of the customer's shipping address (with a limit of 40).

In the following scenario's this introduces issues:

  1. The customer has placed an order with a post office box address. In this case, a search is performed using a post office box postal code, which does not contain any results.
  2. The customer has placed an order with an invalid postal code. In this case, the search does not contain any results.
  3. The customer has selected a ServicePoint that is not near the customer's shipping address. In this case, the search returns up to 40 ServicePoints close to the shipping address, but does not include the selected ServicePoint.

In the first two scenario's, clicking on the "Submit shipment" button results in a "Cannot create shipment" error message, and the following is logged to the exception.log:

main.CRITICAL: Notice: Undefined index: method_options in /path/to/magento/vendor/dhlparcel/magento2-plugin/Observer/Shipment.php on line 177 {"exception":"[object] (Exception(code: 0): Notice: Undefined index: method_options in /path/to/magento/vendor/dhlparcel/magento2-plugin/Observer/Shipment.php on line 177 at /path/to/magento/vendor/magento/framework/App/ErrorHandler.php:61)"} []
petraheuts commented 4 years ago

Hi Aad, Also this feature is added in our new release :)

roerlemans commented 4 years ago

Thanks Aad, for your time you take to provide us the right information!

This issue should be fixed in our latest release. Thank you for your contribution!