How to generate a unique code for each individual coupon item purchased within a single transaction.

  • bcsform
    Asked on July 9, 2025 at 3:33 AM

    I am creating a coupon sales form where each coupon item sold must have a unique code. These unique codes will later be used for a prize spinning draw. Currently, I know how to generate a unique code per transaction or form submission using a unique code widget, but I need to generate a unique code for each individual coupon item purchased within a single transaction. How can I implement or automate the generation of unique codes for every coupon item sold, rather than just one code per transaction? Are there recommended methods, widgets, or integrations that support assigning multiple unique codes per purchase and ensure that each code is distinct and trackable for prize selection?

  • Podo: Support AI Agent
    Replied on July 9, 2025 at 3:33 AM

    Hi Charles,

    Thanks for reaching out to Jotform Support. I'm an AI assistant. I'll do my best to help you until someone from the support team is available.

    To generate unique codes for each individual coupon item purchased within a single transaction, rather than one code per transaction, you can use a combination of Jotform widgets and features:

    • Use the Inventory Widget or Ticket Purchases Widget to list coupon items with available quantities.
    • Set up quantity selectors for each coupon item so customers can select multiple quantities.
    • Use the Unique ID Widget configured to generate a unique code for each item quantity selected. This may require some form calculation or custom scripting to assign unique codes per item.
    • Alternatively, manage unique codes externally and integrate them via payment or form submission data.

    This approach ensures each coupon item sold has a distinct, trackable code for your prize draw.

    Give it a try and let us know how it goes.

  • bcsform
    Replied on July 9, 2025 at 3:40 AM

    After trying the AI’s suggestion, it seems the solution does not fully meet my needs. I believe I should or prefer to continue using the Product List widget because it makes it easier for me to calculate the total payment amount for each transaction. With the Product List, I can manage product options and pricing more conveniently within a single form, although the challenge remains how to generate unique codes for each coupon item purchased.

    Perhaps the best approach is to combine the Product List with an external system or custom scripting to create unique codes per item, so that both the payment process and coupon code tracking run smoothly and fit my giveaway requirements.

  • Podo: Support AI Agent
    Replied on July 9, 2025 at 3:40 AM

    Hi Charles,

    Thank you for the update. A member of our Support Team has now taken over your thread and will assist you further with combining the Product List widget and external solutions for generating unique codes per coupon item.

    Feel free to follow their guidance for the best outcome.

  • Christine JotForm Support
    Replied on July 9, 2025 at 3:43 AM

    Hi Charles,

    I’ll need a bit of time to look into this. I’ll get back to you as soon as I can.

    We appreciate your patience while we work on a solution.

  • Christine JotForm Support
    Replied on July 9, 2025 at 6:22 AM

    Hi Charles,

    Unfortunately, it is not possible to generate a unique code for each item using the Product List element. As a workaround, you can use a Random Value Generator widget to generate a Unique Code for the ticket. The code that will be generated will only show on the Tables and Email Notification. You can pass the price of each ticket using a Form Calculation widget to your Payment Gateway. Let me show you how:

    1. In Form Builder, click on Add Element on the upper left side of the page.
    2. Add a Dropdown element for the number of tickets they are allowed to purchase.
      a. Click on the gear icon.
      b. Under Options tab, add the number of tickets the user's are allowed to purchase. How to generate a unique code for each individual coupon item purchased within a single transaction Screenshot 110
    3. On the Form Elements list, click on Widget tab and add Random Value Generator Widget depending on the number of tickets allowed to purchase. How to generate a unique code for each individual coupon item purchased within a single transaction Screenshot 121
    4. You can configure the value that will be generated, if you want it in Numbers, Alphanumeric or Letters only.
      a. Click on the Random Value Generator widget and click the wand icon.
      b. Under General tab, click on the dropdown for Allowed Characters and select your preferred character.
      c. Click Update on the lower right of the page to save the changes. How to generate a unique code for each individual coupon item purchased within a single transaction Screenshot 132
    5. To calculate the price of each ticket, you need to add a Form Calculation widget.
      a. On the Form Elements list, click on Widget tab and add Form Calculation Widget.
      b. On the Form Calculation widget, click on the wand icon.
      c. For the Formula, click on Add Field and select Number of Tickets field then click on the multiply icon and the price amount of each ticket. Click Save. How to generate a unique code for each individual coupon item purchased within a single transaction Screenshot 143
      e. See sample formula below:How to generate a unique code for each individual coupon item purchased within a single transaction Screenshot 154
    6. Now hide the Random Value Generator widget and Form Calculation widget.
      a. Press CTRL key or command key on your keyboard and select all the Random Value Generator widget and Form Calculation widget.
      b. Click Hide button on the upper right corner of the page. How to generate a unique code for each individual coupon item purchased within a single transaction Screenshot 165
    7. On the Elements List on the left side panel of the page, click on Payment Tab and your preferred Payment Gateway.
    8. Connect your Payment account and on the Payment Type select User Defined Amount and click Yes, Change on the pop up window. How to generate a unique code for each individual coupon item purchased within a single transaction Screenshot 176
    9. Click on the User Defined Amount icon and set Get Price From option to the Form Calculation Widget. How to generate a unique code for each individual coupon item purchased within a single transaction Screenshot 187
    10. Lastly, apply Condition to show the tickets depending on the quantity they will purchase.
      a. Click Settings on the orange navigation bar.
      b. Click Conditions on the left side panel on the page the click Add Condition.
      c. Select Show/Hide Field.
      d. Copy Condition below and click Save. Add same condition depending on the number of tickets they will purchase.How to generate a unique code for each individual coupon item purchased within a single transaction Screenshot 198

    See screencast below for the result: How to generate a unique code for each individual coupon item purchased within a single transaction Screenshot 209

    Here's my demo form that you can clone for your reference.

    Give it a try and let us know how it goes.