strangerstudios / pmpro-group-discount-codes

Adds features to PMPro to better manage grouped discount codes or large numbers of discount codes.
https://www.paidmembershipspro.com/add-ons/group-discount-codes/
6 stars 9 forks source link

Email admins if group code used multiple times #12

Open dparker1005 opened 1 year ago

dparker1005 commented 1 year ago

Is your feature request related to a problem? Please describe. In #11, we are no longer counting a group code as "used" until an order is completed with that code. This can cause issues when, for example, multiple users try to check out for the code with Stripe Checkout at the same time. Since the code is not considered used until the checkout is complete, both users could get to Stripe Checkout using the same group code as long as neither checkout has yet been completed.

Describe the solution you'd like Since there isn't a great way to prevent this issue from happening, we should try to notify administrators when it does. This can be done in the pmpro_groupcodes_pmpro_discount_code_used() function by first checking if there is already an order ID for the group code and, if so, emailing the admin so that they are aware of the issue and can sort it out on their end.