I save to DB at the same time as generating the codes. In the above cart example, I'm seeing twice as many sql entries than I should (I'm seeing 8 instead of 4). I noticed too that the Thank You page is shown in duplicate and the codes for each is a different set.
So the question is:
"How many times is the code generator called in this example?"
What am I doing wrong here? I feel like there is some very useful info that I'm missing.