You can add new coupons and reuse existing codes. This causes errors when loading a coupon by its code, as its unknown (or incorrect) which promotion that is loaded.

Comments

mglaman created an issue. See original summary.

vasike’s picture

Assigned: Unassigned » vasike

let's try it

vasike’s picture

Status: Active » Needs review

and there is a PR for this
https://github.com/drupalcommerce/commerce/pull/659

p.s. i also added a Validation test for Coupons there.

bojanz’s picture

We can follow core's example and just extend the existing constraint, which means that we can customize the message without needing to write our own validator class.

bojanz’s picture

Done.

Also replaced the "A coupon with code %value already exists. Enter a unique code." message with "The coupon code %code is already in use and must be unique." to make it match the SKU message. We can change both at the same time if we don't like the phrasing.

Waiting on travis before push: https://travis-ci.org/drupalcommerce/commerce/jobs/209730881

  • bojanz committed a7d06cb on 8.x-2.x authored by vasike
    Issue #2855836 by mglaman, vasike, bojanz: Coupon codes need unique...
bojanz’s picture

Status: Needs review » Fixed
mglaman’s picture

Yay!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.