{"action":"created","issue":{"url":"https://api.github.com/repos/Sylius/Sylius/issues/6255","repository_url":"https://api.github.com/repos/Sylius/Sylius","labels_url":"https://api.github.com/repos/Sylius/Sylius/issues/6255/labels{/name}","comments_url":"https://api.github.com/repos/Sylius/Sylius/issues/6255/comments","events_url":"https://api.github.com/repos/Sylius/Sylius/issues/6255/events","html_url":"https://github.com/Sylius/Sylius/issues/6255","id":180270543,"number":6255,"title":"[Promotion] Unable to use the same coupon code for multiple promotions","user":{"login":"steffenbrem","id":1569156,"avatar_url":"https://avatars.githubusercontent.com/u/1569156?v=3","gravatar_id":"","url":"https://api.github.com/users/steffenbrem","html_url":"https://github.com/steffenbrem","followers_url":"https://api.github.com/users/steffenbrem/followers","following_url":"https://api.github.com/users/steffenbrem/following{/other_user}","gists_url":"https://api.github.com/users/steffenbrem/gists{/gist_id}","starred_url":"https://api.github.com/users/steffenbrem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/steffenbrem/subscriptions","organizations_url":"https://api.github.com/users/steffenbrem/orgs","repos_url":"https://api.github.com/users/steffenbrem/repos","events_url":"https://api.github.com/users/steffenbrem/events{/privacy}","received_events_url":"https://api.github.com/users/steffenbrem/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-09-30T10:23:37Z","updated_at":"2016-09-30T11:07:26Z","closed_at":null,"body":"I just stumbled onto this and I think the code should not be unique, since you can have multiple promotions that could be active with the same coupon code. Is this intentional or just a missing feature?"},"comment":{"url":"https://api.github.com/repos/Sylius/Sylius/issues/comments/250718563","html_url":"https://github.com/Sylius/Sylius/issues/6255#issuecomment-250718563","issue_url":"https://api.github.com/repos/Sylius/Sylius/issues/6255","id":250718563,"user":{"login":"steffenbrem","id":1569156,"avatar_url":"https://avatars.githubusercontent.com/u/1569156?v=3","gravatar_id":"","url":"https://api.github.com/users/steffenbrem","html_url":"https://github.com/steffenbrem","followers_url":"https://api.github.com/users/steffenbrem/followers","following_url":"https://api.github.com/users/steffenbrem/following{/other_user}","gists_url":"https://api.github.com/users/steffenbrem/gists{/gist_id}","starred_url":"https://api.github.com/users/steffenbrem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/steffenbrem/subscriptions","organizations_url":"https://api.github.com/users/steffenbrem/orgs","repos_url":"https://api.github.com/users/steffenbrem/repos","events_url":"https://api.github.com/users/steffenbrem/events{/privacy}","received_events_url":"https://api.github.com/users/steffenbrem/received_events","type":"User","site_admin":false},"created_at":"2016-09-30T11:07:26Z","updated_at":"2016-09-30T11:07:26Z","body":"To support this behaviour, I think the best thing would be to remove the `promotionCoupon` from the `Order` and use string property `couponCode` (isn't necessary to make it work, but it would be a lot cleaner). Then we can use this code in the `CouponsEligibilityChecker` and use it something like this:\r\n\r\n```php\r\nprotected function isCouponEligible(PromotionInterface $promotion, PromotionCouponAwareSubjectInterface $subject)\r\n{\r\n    $coupon = $this->couponRepository->findOneByCodeAndPromotion($subject->getCouponCode(), $promotion);\r\n\r\n    if (null === $coupon) {\r\n        return false;\r\n    }\r\n\r\n    return $this->isCouponEligibleToLimit($coupon, $subject->getCustomer());\r\n}\r\n```\r\n\r\nThe reason to use the repository to fetch the actual coupon entity is for better performance, sometimes you have thousands of coupons.\r\n\r\nWith only these changes I think the coupons system is much more flexible. WDYT?\r\n"}}
{"actor":{"display_login":"steffenbrem"}}