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 I apply a promotion with two actions, the usage count goes up by two #11879

Open
yedhukrishnan opened this issue Apr 27, 2023 · 1 comment

Comments

@yedhukrishnan
Copy link

yedhukrishnan commented Apr 27, 2023

I created a promotion with two actions:

  1. A whole order adjustment with a flat percentage of 100%
  2. Free shipping

When I successfully apply this coupon and checkout, the current usage goes up by 2.

Context

We use the credits_count method to show the current usage. The credits method is defined as follows:

def credits
  Adjustment.eligible.promotion.where(source_id: actions.map(&:id))
end

In the scenario above, the order has two adjustments: one for shipping and one for the order itself.

Is this an expected behavior? When I set the usage limit to 5, I expect the promotion to be applied to 5 orders. But now, I must set it to 5 times the number of adjustments to be applied to the order.

Expected Behavior

I expect the usage count to increase by one when I apply the above coupon to the order.

Actual Behavior

The usage count went up by two since the order had two adjustments.

Your Environment

  • Version used: 4.4.0

Please let me know if I need to do anything differently here or if my understanding of how the credits work needs to be corrected. I was not able to find documentation on it anywhere.

@jonathankroll13
Copy link

This same issue happens if you have a line item-based promotion (since spree doesn't do whole order adjustments for tax calculations. See #10907) and you have multiple items in the order. The number of usages ends up being the amount of line items there are. If you have a usage limit set to 1, only one line item gets the promotion. Not sure if the root cause is the same here, but it seems related.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants