At the point of coupon code generation, allow user to control:

  • The length of the code (if different to default length of coupon type)
  • The character case of the code
  • Whether or not to include alphanumeric or just alphabetical characters in the code

Comments

ruscoe’s picture

ruscoe’s picture

Status: Active » Needs review
joelpittet’s picture

This looks like a nice UI change, did you consider maybe an alter hook too? Then the control can be given to the devs as well?

mdupree’s picture

As for the Joel's option in #3. Not sure how to implement the alter hook.
But I Reviewed patch #1, all seems to be working ! Great job !

mdupree’s picture

Status: Needs review » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 1: commerce_coupon-generated-coupon-options-2301815-1.patch, failed testing.

torgospizza’s picture

Patch is pretty old so it's gonna need a re-roll.

mdupree’s picture

Hopefully I did this correctly, but I re rolled the patch, all applies cleanly.

mdupree’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 8: commerce_coupon-generated-coupon-options-2301815-2.patch, failed testing.

The last submitted patch, 8: commerce_coupon-generated-coupon-options-2301815-2.patch, failed testing.

mdupree’s picture

Status: Needs work » Needs review

Test failed because it couldn't find file at line 6 of the patch ( commerce_coupon.module ) not sure why that's happening. If someone know's and would like to explain would be much appreciated.
Other then the failed test the patch does apply clean to latest dev release.

torgospizza’s picture

What command did you use for your patch creation? It looks like you used your IDE to generate it - you might try from command-line instead.

The main difference I can see from your patch and the one above that worked is a missing slash in the front (/commerce_coupon.module) which makes me think you may either need a flag, or may need to remove a flag (for instance --relative).

I also can't tell from the patch if you generated it using the Drupal git repo's version of the module or one from your local working copy? If you use the Drupal git repo as your root level it may go more smoothly.

Hopefully one of these clues will help!

mdupree’s picture

@torgosPizza I did indeed use the IDE to produce the patch, the module was pulled from drupal using git. I will use your tips and try again using command line!
Thanks for the help.

mdupree’s picture

Trying again for patch test !

das-peter’s picture

Jut got the requirement to be able to introduce a pattern into generated coupon codes. As this issue already takes care of adjusting commerce_coupon_generate_coupon_code() I pick up the idea of @joelpittet in #3 and introduce an alter hook.
A working example of how to use the new hook has been added to the api documentation file.

das-peter’s picture

Created #2949884: Allow user greater control over generated coupon codes to bring the new features to "Commerce coupon batch" as well.

chris matthews’s picture

Priority: Minor » Normal
Status: Needs review » Reviewed & tested by the community

The patch in #15 applied cleanly to 7.x-2.x-dev and is an excellent improvement to the module! I tested different combinations of 'Use alphanumeric characters' and 'Use uppercase characters' and the randomly generated code came out correctly each time. I would love to see this get committed to 7.x-2.x so it's included in the next release (7.x-2.0 was released in July 2017)

torgospizza’s picture

@Chris2: Did you try das-peter's patch in #16?

chris matthews’s picture

Ah, sorry about that. das-peter's patch in #16 also applied cleanly to 7.x-2.x-dev and the alter_hook steps up the improvement even more for devs.