postnl / postnl-magento2

This is the official Magento 2 extension for the logistics company PostNL. Add shipping options and parcelshops to your checkout. Create labels with track and trace functionality from the backend.
58 stars 61 forks source link

[QUESTION] Selecting alternative delivery when creating orders through Magento API #339

Closed ThomasMW closed 4 months ago

ThomasMW commented 1 year ago

In our Magento instance we have the setting for the alternative delivery 'Extra cover' when an order is above a specific amount. This works fine when using the store-front checkout. However I would like to be able to also use this alternative delivery when creating orders through the Magento API.

When adding the shipping information to an order using the Magento API you add to the following to the payload;

"shipping_method_code": "regular",
"shipping_carrier_code": "tig_postnl"

When creating orders through the API which have an amount higher than the threshold the alternative delivery isn't applied to the order.

Is it possible to simply replace the shipping_method_code with the alternative delivery and if so where can I find all available shipping method codes? I tried accessing the documentation but as of yet I haven't been granted access.

tig-jeffreybranderhorst commented 1 year ago

Hey @ThomasMW ,

The shipping_method_codes that there are available are: pakjegemak, extra@home, regular, letterbox_package. Via the API you can also send along product codes, Product code 3087 is for extra cover.

That the documentation is not available right now is correct, we are aware of this and working on it. You can see all the API call in swagger if you want.

Have a great day, Jeffrey

ThomasMW commented 1 year ago

Hi @tig-jeffreybranderhorst

I used swagger to inspect the /shipping-information endpoint but I can't quite make out where the product code would go in the payload. Is it supposed to be added as a custom attribute?

    "custom_attributes": [
      {
        "attribute_code": "string",
        "value": "string"
      }
tig-jeffreybranderhorst commented 1 year ago

Hi @ThomasMW ,

When creating a Magento Shipment you also need to create a PostNL shipment. This is done after the shipment has been created.

Once using an API key in swagger that has rights to see everything. You can see the tIGPostNLShipmentManagementV1 In here you have the /v1/postnl/shipment/{shipmentId}/createShipment here you van give { ‘productCode’: 0, ‘colliAmount’: 0 } In here you van add the correct product code that you want to use and also the colli amount In your case you would use 3087 as the product code. This is the code for Extra Cover.

Hope the explanation of my colleague helps you further!

Have a great day, Jeffrey

ThomasMW commented 1 year ago

Are we talking about the same type of shipment?

Perhaps it wasn't clear I was referring to /rest/V1/guest-carts/cartid/shipping-information, which is used to add the shipping information during the order creation.

I assume I need to create, or perhaps edit, a PostNL order which is stored in the table tig_postnl_order. I see these orders can be accessed at /V1/postnl/orders. Is this what you are referring to?

tig-jeffreybranderhorst commented 1 year ago

Hi @ThomasMW ,

I have placed this on our backlog because we found out that there is an issue with an after method on the save. Because of this issue, the methods like extra cover won't be passed on to the backend.

We are going to investigate this further and make a fix in a future release, thank you for submitting this.

Have a great day, Jeffrey

ThomasMW commented 1 year ago

Hi @tig-jeffreybranderhorst

Any progress regarding this issue?

tig-vincentthart commented 1 year ago

Hi @ThomasMW,

It is on our backlog to be picked up, but it hasn't been resolved yet.

When we have a solution, we will check if we can share a patch with you before the release.

Have a nice day, Vincent

ThomasMW commented 12 months ago

@tig-vincentthart @tig-jeffreybranderhorst So we're closing in on this issue being almost a year old. Is there any progress or eta available for when this will be resolved?

JorisPostNL commented 4 months ago

Hi @ThomasMW, unfortunately we do not have the space to include this feature on our roadmap at this moment due to ongoing development in other areas. We will keep this on our backlog for future development once there is more room on our roadmaps.

Kind regards Joris PostNL Support

ThomasMW commented 4 months ago

Understood, thanks for getting back to me @JorisPostNL