Add a tool for generating multiple codes for a promotion
zostay - June 7, 2007 - 14:26
| Project: | Promotion |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | tcowley |
| Status: | needs work |
Description
A promotion administrator can specify a pattern and then have the promotion module generate N specific codes that match that pattern. This is similar to the E-Commerce Coupon module, but you pick the format of the codes generated.
This requires that multiple codes can be associated with a promotion.

#1
Change made:
Added new promotional code type of 'Auto-generated code'. This is for pre-generating a list of unique codes. (They look like this, for example: '3URF43RHTK53SLRT').
How it works:
How code generation works:
#2
Patch file one of two:
#3
patch file two of two.
#4
#5
Thanks for the patch. I've not had time to mess with the Promotion module for a bit, but I'll see about patching it in as soon as I have a chance to look it over.
#6
I've finally had time to take a look at the patch. The algorithm provided does provide a nice way to generate a series of codes and provides a pretty simple way to verify the correctness of a code without having to store all the codes in the database. The code generator is sufficiently lossy to prevent someone from guessing too, which is a bonus above the other code formats currently available.
However, I have a few concerns I'd like to discuss before incorporating the patch or a revision of it.
First, the format of the codes is limited to a jumble of hexadecimal numbered codes that contains a U in them somewhere at the mid-point. It would be nice if the codes could be prefixed and/or suffixed for marketing purposes. My marketers get nervous when there isn't something like a recognizable product or service abbreviation in the codes they hand out. It might also be nice to make the codes use the full alphanumeric range rather than just [0-9A-F].
Second, the range of possible codes is somewhat limiting. I don't imagine that our company or many others will ever need to generate more than 100,000 codes, but I can imagine wanting codes that are shorter than 10 characters that are still sufficiently random. This would be more possible if the strings used all letters rather than just the hexidecimal characters.
Third, it currently allows the number of characters specified to be up to be between 10 and 30. But unless I'm mistaken, the actual possible range is 10 to 21 since the sequence prefix is 5 characters and the length of an MD5 sum is 16, which gives you maximum length of 21.
Anyway, I'd be interested to hear your thoughts or the thoughts of others.
#7
Thanks for reviewing the code and feature changes. Your concerns/recommendations sound good to me.
The original feature was designed to meet a specific client requirement, and it could certainly use the upgrade to more flexibility.
I'll roll these upgrades into the code in the next week or two, along with some revised documentation!