Skip to content
This repository has been archived by the owner on Jul 3, 2024. It is now read-only.

Checkout TotalPrice is counting shipping price twice #9

Closed
GrzegorzKrauze opened this issue Jun 17, 2024 · 2 comments
Closed

Checkout TotalPrice is counting shipping price twice #9

GrzegorzKrauze opened this issue Jun 17, 2024 · 2 comments

Comments

@GrzegorzKrauze
Copy link

Using shipping broker as a delivery method source.

Scenario:

  1. not logged in user is adding one (or more) product into the new cart -> a new guest cart is created with this product as a item

  2. user goes to the cart, and goes to the avarda checkout -> user can see shipping methods. There is also a items call:
    https://stage.checkout-api.avarda.com/api/partner/payments/{purchaseid}/items . It adds the selected product as a item in given purchaseId in Avarda

  3. update request is called -> Avarda API is sending request for update and it receives the correct amount in TotalPrice, which is "subtotal" + "selected shipping method price"

  4. User refreshes the checkout -> The items are sent again to avarda but this time the qoute shipping is added as a item.

  5. In result on the update request, the selected shipping price is added twice.

When I patched the code not to add a shipping as a item in the quote then it is working as expected:
-> when the shipping is already chosen and the user is refreshing the page - the amount is not increased by the additional shipping cost
-> when placing the order the "shipping item" is added.

My patch only commented this line as a workaround:

Referring this line
https://github.com/avarda-ab/Magento2-Checkout-module/blame/3c99643f1b20a053c7240ac8b91cab1416dfaff0/Plugin/Model/Quote/QuoteCollectTotalsPrepareItems.php#L179

Is it necessary to add the "shipping item" from the cart shipping address in any case?

@GrzegorzKrauze
Copy link
Author

In other words the difference is on enter the checkout page, when the module is sending

PUT https://stage.checkout-api.avarda.com/api/partner/payments/{purchaseid}/items
  1. If user is refreshing (or getting back to) the checkout page - the "shipping item" is added here
  2. If the user is entering the checkout page the first time - only the product items are added to avarda with this PUT request

after the "1 point" scenario the "update" request to avarda is adding a selected shipping on top of already added items. So if you added one product and entered the checkout module twice you have 3 items in avarda purchase, from which 2 are shippings.
after the "2 point" scenario the "upfate" request is also adding a shipping method item but there is no extra item here.

Of course this is the case on the shipping broker variant.
I haven't had occasion to test it with the regular magento-defined delivery methods.

@GrzegorzKrauze
Copy link
Author

I've moved it to the correct module version:
avarda-ab/Magento-2-Checkout-3-module#48

@GrzegorzKrauze GrzegorzKrauze closed this as not planned Won't fix, can't repro, duplicate, stale Jun 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant