10 Replies Latest reply on Jan 17, 2013 4:15 PM by Liam Dilley

    Programmatically entering Discount Codes

    SandySandeep Level 1

      I am using Adobe business catalyst as Admin control for my shopping cart and I want to put a deal in groupon of my products, where in the customer can buy the deal from groupon and use that discount code that he gets while shopping at my site. So my question is I need to create discount codes for each buy made at groupon of my deal. If say 500 users have bought the deal than I have to create 500 unique discount codes. Can this be done programmatically. If so can anyone explain me how? If not what would be the best way to do this apart from manually entering 500 disocunt codes.


      Thank You


        • 1. Re: Programmatically entering Discount Codes
          mario_gudelj Most Valuable Participant

          Hi Sandy,


          The only way to create discount codes is by manually entering them into site admin. There's unfortunately no other way to do it at this stage.





          • 2. Re: Programmatically entering Discount Codes
            Liam Dilley Adobe Community Professional & MVP

            Can back this up, tried a variety of scripts but the BC stuff breaks it.


            Only thing you can do is do a peace of content that shows if some conditions based on what is in the cart is matched and shows some text that says "You qualify for a discount, enter xxxx to in the discount area to enter it".

            • 3. Re: Programmatically entering Discount Codes
              Mihai_Tica Adobe Employee

              Have you used iMacros? It is a free FireFox extension - http://wiki.imacros.net/iMacros_for_Firefox


              I used it successfully for working with certain areas of the BC console (cases and forums) and the Partner Portal. Not sure it will work for discount codes but it might be worth a shot.

              • 4. Re: Programmatically entering Discount Codes
                Liam Dilley Adobe Community Professional & MVP

                That is not viable for a working website.

                • 5. Re: Programmatically entering Discount Codes
                  Mihai_Tica Adobe Employee

                  Why not? Take a look at this tutorial - http://wiki.imacros.net/Demo-Loop-Csv-2-Web - that bacically loops through a .csv, copies the values there, pastes them into a webform and submits them.


                  I am thinking something similar could work for mass importing discount codes too. Of course targeting the various elements of the admin console is more trickyer than filling and submitting a form but in theory it should work, what do you say?

                  • 6. Re: Programmatically entering Discount Codes
                    Brad Lawryk Adobe Community Professional & MVP

                    Well I think the biggest problem would be that not everyone uses Firefox?

                    • 7. Re: Programmatically entering Discount Codes
                      SandySandeep Level 1

                      Thanks to all for the responses, problem solved. Kudos to Mihai Tica, your idea worked perfectly....It reduced me a lot of manual work. I am pasting my macro as a reference to others.....

                      VERSION BUILD=7401110 RECORDER=FX

                      TAB T=1

                      CMDLINE !DATASOURCE C:\\YourFilePath\\Book1.csv

                      'Number of columns in the csv file:

                      SET !DATASOURCE_COLUMNS 2

                      'Increase the current position in the line

                      SET !DATASOURCE_LINE {{!LOOP}}

                      URL GOTO=http://www.YourSitename.com/Admin/Catalogues_DiscountCodes.aspx

                      TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:aspnetForm ATTR=ID:ctl00_cp_txtdescription CONTENT=samle{{!COL1}}

                      TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:aspnetForm ATTR=ID:ctl00_cp_txtdiscountCode CONTENT=dd1{{!COL2}}

                      TAG POS=1 TYPE=INPUT:RADIO FORM=ID:aspnetForm ATTR=ID:ctl00_cp_radioTypeFixed

                      TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:aspnetForm ATTR=ID:ctl00_cp_txtDiscountPercentage CONTENT=10

                      TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:aspnetForm ATTR=ID:ctl00_cp_txtDiscountAmountThreshold CONTENT=26

                      TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:aspnetForm ATTR=ID:ctl00_cp_txtXUses CONTENT=1

                      TAG POS=1 TYPE=INPUT:CHECKBOX FORM=NAME:aspnetForm ATTR=ID:ctl00_cp_chkCatalogues CONTENT=YES

                      TAG POS=1 TYPE=SELECT FORM=NAME:aspnetForm ATTR=ID:ctl00_cp_listCatalogues CONTENT=%248268

                      TAG POS=1 TYPE=DIV ATTR=ID:ctl00_cp_panelCatalogues

                      TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:aspnetForm ATTR=ID:ctl00_cp_btnUpdate


                      Thanks again to all and Mihai Tica :-)

                      1 person found this helpful
                      • 8. Re: Programmatically entering Discount Codes

                        Hey! Could you write me an example of this? its just what I am looking to do!



                        • 9. Re: Programmatically entering Discount Codes
                          AtlantaWebDesignGA.com Level 1



                          Sorry I didn't your message earlier. I had to write a tutorial on how to import Discount Codes for one of my clients who does this all the time, and it has a complete example and explanation of how to automatically read in discount codes from a CSV file and have iMacros fill that into the BC Admin form. Link to my blog: How To Import Discount Codes


                          SandySandeep's script above is a very good start, but there is now some code missing from that which is essential to get BC to do this more realiably in the current BC version. Namely...


                          1) BC renders the discount form within an iframe so your script has to deal with that iframe, as my tutorial shows

                          2) Unless you put Wait commands in the script to slow down form submission, BC's server won't keep up with the script and will throw errors.  Even with the wait commands, BC still may drop a few discount codes when you are importing 500, and I explain how to deal with that.


                          How To Import Discount Codes has a complete iMacro script you can copy, and it also shows how to populate the fields so the Discount Code is limited to certain BC catalogues and how to set the effective and expiry dates for the discount.


                          I have used iMacros for a long time to not only import data into BC Admin that BC normally can't import, but also to populate forms on the public front ends of websites when there is no way in BC to import it.


                          iMacros is also handy to read data off existing websites and save it into a data file, so you can import it into BC. It's pretty cool considering it is free. I use the FireFox add-on and haven't tried the IE or Chrome version yet, so can't vouch if they work as well.


                          Jonathan at AtlantaWebDesignGA.com

                          • 10. Re: Programmatically entering Discount Codes
                            Liam Dilley Adobe Community Professional & MVP

                            Or even understands plugins, as well as a few things. Mihai, I think the 4 things wrong with this should be obvious I will be worried if they not