Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When remove an item the shipping is not updated correctly #2540

Closed
giosueDelgado opened this issue Nov 23, 2023 · 7 comments
Closed

When remove an item the shipping is not updated correctly #2540

giosueDelgado opened this issue Nov 23, 2023 · 7 comments
Assignees
Labels
type: bug 🐛 Something isn't working

Comments

@giosueDelgado
Copy link
Collaborator

Describe the bug
When I use the removeItemFromOrder the shipping is not updated correctly.

The problem is that the applyPriceAdjustments inside the orderservice not take care of the configuration of "await this.orderCalculator.applyPriceAdjustments" where there is a option that ask for recalculate the shipping.

To Reproduce
Steps to reproduce the behavior:

  1. Add one item with one shipping method
  2. Add another item with another shippin method
  3. Remove the first item
  4. The shipping is wrong without call the setshippingmethod (force the recalculation)

Expected behavior
Add the option also in the services of orderservice (removeItemFromOrder, addOrderItem, ecc..) all service that inside use the applyPriceAdjustments to give the possibility to recalculate the shipping.

Environment (please complete the following information):

  • @vendure/core version: 2.1.1
  • Nodejs version 16
@giosueDelgado giosueDelgado added the type: bug 🐛 Something isn't working label Nov 23, 2023
@michaelbromley
Copy link
Member

Hi,

Can you test this against the latest version, v2.1.3? That release contains this fix which may be related:

@giosueDelgado
Copy link
Collaborator Author

Sure I can test but I see in the code also in the latest version that the flag to recalculate the shipping is never set to true so I don't think it resolve. The issue in my opinion is that when for example I call the removeOrderLine in my service the output of that is a order updated also for shipping if no-one line is using this shippingline.

@giosueDelgado
Copy link
Collaborator Author

And this can be done, in my opinion, if in the applyPriceAdjustments there is also the update of the shipping price based on the strategy of the shippingorderlinestrategy what do you think?

@michaelbromley
Copy link
Member

The "recalculateShipping" flag effectively defaults to "true":

if (options?.recalculateShipping !== false) {
await this.applyShipping(ctx, order);
await this.applyShippingPromotions(ctx, order, promotions);
}

I'm struggling to clearly understand the reproduction. Can you provide exact steps including the exact sequence of queries & mutations required to reproduce?

@giosueDelgado
Copy link
Collaborator Author

Ok, I checked deeper the problem.

I was thinking that "when I add an item to the cart (calling addOrderItem for example) in the service core also the logic to associate the line to the shipping line was running" but in reality, this is done only in the setShippingMethod of orderService.

In our use case when a user add an item it set also the type of shipping and we set using the customfield on order line.

So I don't know if is correct what I thinking or not let me know if I was clear.

@giosueDelgado
Copy link
Collaborator Author

@michaelbromley

@michaelbromley
Copy link
Member

@giosueDelgado I've made a fix for the next patch (2.1.6) that includes a fix for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug 🐛 Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants