We are getting ready to do a Groupon promotion that will discount memberships. Groupon has generated individual "voucher codes" for each person who purchases. I need to enter each of these voucher codes as a single-use discount code. I'd like to be able to enter up to 200 codes at once, all with the same usage limits and rules, but so far, I can't figure out how to do this except to enter each code manually and set all the rules each time. When I try to just copy one code to avoid having to set all the rules each time, the copy shows a randomly-generated code that can't be edited. Has anyone figured this out?
I upvoted Zachary's answer, but I felt conflicted. I do NOT recommend importing directly to MySQL, because you end up bypassing validation logic and could create corrupt discounts. However, their suggestion of the API CSV Import GUI is a good one, and the one I'd recommend.
If you're not sure what the values should be for your various columns, go to Support menu » Developer » API Explorer. Set your entity to DiscountCode and action to Get and press Execute. You'll get something much like you're seeing below. In the "Results" screen you can see the values, which you can copy/paste. If you already had discount codes, you may need to scroll down to find one that matches the ones you want to enter. You can click "Add Option" to set Limit to 0 if you can't see the full list.
It might be possible to import the codes directly into the database using a tool like PHPMyAdmin with the proper formatting.
The table which contains your codes is 'cividiscount_item'. It contains 18 fields. If you were able to generate a code in CiviDiscount which defined the same usage limits/rules, you could essentially use that as a 'template' for the other codes you imported - assuming it was the same for all of the codes you needed to bring in.
There are various ways to import or create the codes in mySQL, either using some insert/update statements, or import from CSV. The fields in the database which contain the codes rules/logic are serialized, but I am assuming you could use a statement to update the codes you imported fields from the original one without losing any data integrity.
You could also just copy the code 199 times (ouch) and then use PHPMyAdmin to go and update the codes to your liking in the 'Code' field, but I can't see how that would be more efficient. Also, have to be careful about changing things in the database once they have gone into actual use on your site.
The API CSV Import GUI extension also seems to be able to import Discount Codes but you would face the same issues above - might be useful to you: https://civicrm.org/extensions/api-csv-import-gui
Edit, this is also Really Ugly and not preferred, but you can go to CiviDiscount, right-click and edit the code in question in a new tab. Use Chrome Developer Tools (Etc.) by right clicking and "inspecting element" on the discount code field which is uneditable. Change the value to the new code, and then save. I verified this reflected the change in the database. The part you change will look like below. I think this also means developing an extension to change it or even some jquery might be possible - however, there are good reasons to not change a live code. Perhaps the copy function should be overridden to allow code definition?
<span class="crm-form-text big">TESTCHANGING2<input type="hidden" name="code" value="TESTCHANGING2" id="code"></span>