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

fix(medusa): Update line item adjustments upon cart discount removal #2751

Merged
merged 5 commits into from
Dec 12, 2022

Conversation

adrien2p
Copy link
Member

@adrien2p adrien2p commented Dec 9, 2022

What

When a discount is deleted from a cart, the line item adjustments must be refreshed. Now, the cart service removeDiscount includes updating the adjustments.

Tests

Add a new integration test which:

  • create a cart with a discount
  • add a line item
  • validate the adjustments
  • remove the discount
  • check that the adjustments are not present anymore

Update unit tests
The actual tests cases now check that the adjustments repository is called when needed

FIXES CORE-890

@changeset-bot
Copy link

changeset-bot bot commented Dec 9, 2022

🦋 Changeset detected

Latest commit: acd407e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@medusajs/medusa Patch

Not sure what this means? Click here to learn what changesets are.

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

@adrien2p adrien2p marked this pull request as ready for review December 9, 2022 09:57
@adrien2p adrien2p requested a review from a team as a code owner December 9, 2022 09:57
Copy link
Contributor

@olivermrbl olivermrbl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo: We also allow you to remove discounts by sending:

POST /store/carts/{id}
{ discounts: [] }

So we should also fix the update cart flow.

@adrien2p adrien2p requested a review from olivermrbl December 9, 2022 15:00
Copy link
Contributor

@olivermrbl olivermrbl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a minor todo before we merge 🚀

.changeset/young-jobs-wink.md Outdated Show resolved Hide resolved
integration-tests/api/__tests__/store/cart/cart.js Outdated Show resolved Hide resolved
integration-tests/api/__tests__/store/cart/cart.js Outdated Show resolved Hide resolved
integration-tests/api/__tests__/store/cart/cart.js Outdated Show resolved Hide resolved
integration-tests/api/__tests__/store/cart/cart.js Outdated Show resolved Hide resolved
integration-tests/api/__tests__/store/cart/cart.js Outdated Show resolved Hide resolved
@olivermrbl olivermrbl changed the title fix(meduss): Should update the adjustments upon cart discount removal fix(medusa): Should update the adjustments upon cart discount removal Dec 12, 2022
@olivermrbl olivermrbl changed the title fix(medusa): Should update the adjustments upon cart discount removal fix(medusa): Update line item adjustments upon cart discount removal Dec 12, 2022
Copy link
Contributor

@olivermrbl olivermrbl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@adrien2p adrien2p closed this Dec 12, 2022
@adrien2p adrien2p reopened this Dec 12, 2022
@kodiakhq kodiakhq bot merged commit d68e81f into develop Dec 12, 2022
@kodiakhq kodiakhq bot deleted the fix/cart-remove-adjustmenst-upon-discount-removal branch December 12, 2022 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants