medusa icon indicating copy to clipboard operation
medusa copied to clipboard

fix: missing relation when calculating total for cart, item.adjustments

Open dwene opened this issue 2 years ago • 7 comments

This was incorrectly calculating item prices with discounts applied when creating order from cart.

dwene avatar Jul 16 '22 17:07 dwene

⚠️ No Changeset found

Latest commit: 0a650635389599c3eff80389515956993645bad1

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

changeset-bot[bot] avatar Jul 16 '22 17:07 changeset-bot[bot]

@dwene - this doesn't seem to work when we include the adjustments in the service; can't seem to figure out exactly what it is that is causing this issue

srindom avatar Jul 19 '22 14:07 srindom

Hmmm, our issue was that free orders weren't skipping the payment process when completing the cart. When I added that line using the medusa extender, it solved our issue. What isn't working?

dwene avatar Jul 19 '22 22:07 dwene

Or are you just saying there's an issue with the unit tests?

dwene avatar Jul 19 '22 22:07 dwene

Aha, found the issue and fixed.

dwene avatar Jul 25 '22 18:07 dwene

You cant fetch a cart with line_items.adjustments, insert the adjustments manually, and then save the cart without setting those adjustments on the line items. TypeORM gets confused.

dwene avatar Jul 25 '22 18:07 dwene

At some point, it would be good to pick one pattern or another. Either update all the entites off cart in memory, or update them using their individual repositories, not both. I think might be doubling the number of updates called on the database.

dwene avatar Jul 25 '22 18:07 dwene