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

[BUG] Weight calculation not based on item quantity #348

Closed Rick-flashpoint closed 1 year ago

Rick-flashpoint commented 1 year ago

To Reproduce Steps to reproduce the behavior:

  1. Have the following matrix:
    
    NL,*,*,0.0000,0.0000,0,regular,2.0000,
    NL,*,*,5.0000,0.0000,0,regular,15.0000,
    NL,*,*,10.0000,0.0000,0,*,20.0000,
2. If you have a product with the weight of 5KG, 1 should result in a cost of 15, 2 should result in a cost of 20. But at this point, both is will result in a cost of 10
3. you can see the result if you call this: postnl/deliveryoptions/timeframes/:
```JSON
{"error":"Bezorgdagen opties staan uitgeschakeld.","price":15,"timeframes":[[{"fallback":"2-3 werkdagen levertijd"}]]}

The final calculation is correct, but the checkout will show the wrong lower price from the matrix.

Expected result A higher price if items have multiple qty

Actual result Same price in checkout

Workaround change in Service/Carrier/QuoteToRateRequest.php:

return $item->getWeight();

TO

return $item->getRowWeight();

Commit The issue is introduced in this commit: https://github.com/tig-nl/postnl-magento2/commit/a24eb20df64de64d3588a1ce2690655182314d58

Please complete the following information

tig-jeffreybranderhorst commented 1 year ago

Hi @Rick-flashpoint ,

I was able to reproduce this, it happens because the sort order places the NL,,,10.0000,0.0000,0,,20.0000, below the NL,,,5.0000,0.0000,0,regular,15.0000, so it stops the moment it finds NL,,*,5.0000,0.0000,0,regular,15.0000.

I'm going to place this on our backlog to fix, I will also place your solution there, so we can test your solution with multiple scenarios. Thank you for submitting this issue, it will be on our backlog.

Have a great day, Jeffrey

tig-vincentthart commented 1 year ago

@Rick-flashpoint

Thanks again for sharing this fix, we have included it into the latest release v1.12.7.

Greetings

Vincent