Answers.Body: <p>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.</p>
  
  <p>If you're not sure what the values should be for your various columns, go to <strong>Support menu » Developer » API Explorer</strong>.  Set your entity to <strong>DiscountCode</strong> and action to <strong>Get</strong> and press <strong>Execute</strong>.  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 <strong>Limit</strong> to <strong>0</strong> if you can't see the full list.</p>
  
  <p><a href="https://i.sstatic.net/V5cOy.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/V5cOy.png" alt="enter image description here"></a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-07T04:41:53.773Z
Answers.Text: thanks, i learned something here!
Answers.UserDisplayName: Zachary
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-07T03:29:44.773Z
Answers.LastActivityDate: 2019-08-07T03:29:44.773Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.Body: <p>It might be possible to import the codes directly into the database using a tool like PHPMyAdmin with the proper formatting.</p>
  
  <p>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.</p>
  
  <p>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. </p>
  
  <p>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.</p>
  
  <p>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: <a href="https://civicrm.org/extensions/api-csv-import-gui" rel="nofollow noreferrer">https://civicrm.org/extensions/api-csv-import-gui</a></p>
  
  <p>Edit, this is also <em>Really Ugly</em> 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?</p>
  
  <pre><code>&lt;span class="crm-form-text big"&gt;TESTCHANGING2&lt;input type="hidden" name="code" value="TESTCHANGING2" id="code"&gt;&lt;/span&gt;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-06T23:38:32.580Z
Answers.LastActivityDate: 2019-08-07T00:05:11.090Z
Answers.LastEditDate: 2019-08-07T00:05:11.090Z
Answers.UserDisplayName: Zachary
Answers.Body: <p>It looks like <a href="https://civicrm.org/extensions/api-csv-import-gui" rel="nofollow noreferrer">CSV GUI Import to api</a> has the ability to import for Entities</p>
  <ul>
  <li>DiscountCode</li>
  <li>DiscountTrack</li>
  </ul>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-10-01T21:34:44.240Z
Answers.LastActivityDate: 2024-10-01T21:34:44.240Z
Answers.UserDisplayName: petednz - fuzion
Body: <p>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?</p>
  
Tags: <civimember><cividiscount>
Title: Is there a way to upload multiple discount counts into CiviDiscount?
ThreadText: # Is there a way to upload multiple discount counts into CiviDiscount?
  
  (Asked by: username_0 on 2019-08-06)
  
  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?
  
  **Tags:** civimember, cividiscount
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_1 on 2019-08-07. Score: 3
  
  I upvoted username_2'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.
  
  [![enter image description here](https://i.sstatic.net/V5cOy.png)](https://i.sstatic.net/V5cOy.png)
  
  > **Comments:**
  > **username_2**: thanks, i learned something here!  
  
  ---
  
  ### Answer by username_2 on 2019-08-06. Score: 2
  
  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>
  
  ```
  
  
  ---
  
  ### Answer by username_3 on 2024-10-01. Score: 0
  
  It looks like [CSV GUI Import to api](https://civicrm.org/extensions/api-csv-import-gui) has the ability to import for Entities
  
  * DiscountCode
  * DiscountTrack
  
  
  ---
  
  