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

Uniqueness validation added on promotion's code #8067

Merged
merged 1 commit into from Jun 17, 2017

Conversation

Projects
None yet
2 participants
@manishrawat0212
Contributor

manishrawat0212 commented Jun 16, 2017

Issue

Currently, Admin can create multiple promotions having same promo code.
Now, if we apply this promo code in an order, then the first promotion having this promo code will be applied to the order. The later promotions having same promo code will not be considered.

def self.with_coupon_code(coupon_code)
  where("lower(#{table_name}.code) = ?", coupon_code.strip.downcase)
    .includes(:promotion_actions).where.not(spree_promotion_actions: { id: nil })
    .first
end

Fix

Uniqueness validation should be present on promotion's code, like it is present on promotion's path.

@damianlegawiec damianlegawiec merged commit a930930 into spree:master Jun 17, 2017

2 checks passed

ci/circleci Your tests passed on CircleCI!
Details
hound No violations found. Woof!

@manishrawat0212 manishrawat0212 deleted the manishrawat0212:promotion_code_uniqueness_validation_added branch Jun 23, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment