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

Coupon codes assigned to a specific channel working across all channels #2052

Closed
yasserlens opened this issue Feb 25, 2023 · 3 comments
Closed
Assignees
Labels
type: bug 🐛 Something isn't working
Milestone

Comments

@yasserlens
Copy link
Contributor

yasserlens commented Feb 25, 2023

Describe the bug
Coupon codes don't seem to be sandboxed in channels - a coupon code assigned to channel A will also apply to orders in channel B if the coupon code is the same.

To Reproduce

  • Create 2 channels, A & B
  • Switch the admin UI to channel A
  • Create a promotion, call it "flash-sale", action being $20 off.
  • Switch to channel B
  • Create a promo, call it "flash-sale" matching the first promo under channel A.
  • Note, both promotions in channels A and B have the same code.
  • As a client, switch to channel A (pass channel A token with GraphQL requests)
  • run the ApplyCoupon mutation, give it the code "flash-sale"
  • This will apply 2 discounts from both channels on the active order, which is not the expected behavior

Expected behavior
When applying a coupon to an active order given a channel, only that coupon should be applied.
Other coupon codes under different channels, even if the coupon code matches should not be applied.

Environment (please complete the following information):

  • @vendure/core version: 1.9.3
  • Nodejs version: v18.8.0
  • Database (mysql/postgres etc): v18.8.0
@yasserlens yasserlens added the type: bug 🐛 Something isn't working label Feb 25, 2023
@yasserlens
Copy link
Contributor Author

@michaelbromley any chance this is going to make it to the roadmap soon?

@michaelbromley michaelbromley moved this to 📋 Backlog in Vendure OS Roadmap Jun 20, 2024
@dlhck dlhck added this to the v3.0.5 milestone Sep 27, 2024
@michaelbromley michaelbromley moved this from 📦 Backlog to ♻️ In progress in Vendure OS Roadmap Oct 14, 2024
@michaelbromley
Copy link
Member

Hi,

I have tried to reproduce this but I cannot. Here's a video recording where I think I am following the steps you laid out, but only a single promotion gets applied to the order.

issue-2052-repro-attempt.mp4

I did find an error (which is being fixed), which arises because this DB call does not limit to the current channel, which can sometimes result in a valid promo code being rejected (because it fetched a promotion from another channel first).

However, I'm not able to reproduce the scenario of multiple promotions from different channels being applied at once from a non-default channel.

michaelbromley added a commit that referenced this issue Oct 14, 2024
Relates to #2052. When multiple channels have promotions with the same
coupon code, this could cause validation to incorrectly fail
because the DB lookup was not limiting to the active channel.
@yasserlens
Copy link
Contributor Author

Hey Michael

Thank you for this.
I was just about to file a bug for the issue you found - that's been causing us headaches and it was difficult to reproduce which is why we never filed a bug for it. Thanks a lot for the fix!

Regarding this bug - I'm not sure I filed it a long time ago. I got my way around this by making sure the coupons are unique across channels (which is hard to maintain). Feel free to close this bug - if I come across it again and can replicate I'll reopen it. I do look forward to getting the cross channel issue fixed though.

Thanks!

@michaelbromley michaelbromley moved this from ♻️ In progress to 💯 Ready in Vendure OS Roadmap Oct 14, 2024
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
Archived in project
Development

No branches or pull requests

3 participants