Skip to content

Instantly share code, notes, and snippets.

@daverad
Created October 13, 2011 23:43
Show Gist options
  • Save daverad/1285849 to your computer and use it in GitHub Desktop.
Save daverad/1285849 to your computer and use it in GitHub Desktop.
The Goal: I needed a way for us to quickly import the hundreds of Groupon codes into our Shopify site. My Solution: Use iMacros for FireFox to read in the Groupon CSV and automate the process of creating Shopify discount codes.
VERSION BUILD=7000908
'Use groupon csv to automatically create discount codes in shopify.
'####################### ENTER YOUR SETTINGS BELOW #############################
'What is your shopify store name yourshopname.myshopify.com
SET !VAR1 https://fortunecookiesoap.myshopify.com
'How much is your discount? for a $15 discount enter 15
SET !VAR2 15
'When does your discount expire? yyyy-mm-dd
SET !VAR3 2011-04-05
'####################### !!DON'T NEED TO EDIT BELOW THIS LINE!! ################
TAB T=1
TAB CLOSEALLOTHERS
'Specify where the groupon csv file is and what it's called
SET !DATASOURCE groupon-coupons.csv
'Number of columns in the CSV file.(Coupon No.,Customer Name,Status,Redeemed At)
SET !DATASOURCE_COLUMNS 4
'Start at line 2 to skip the header in the file
SET !LOOP 2
'Increase the current position in the file with each loop
SET !DATASOURCE_LINE {{!LOOP}}
'Go to shopify marketing admin page
URL GOTO={{!VAR1}}/admin/marketing
'click on add a discount code link
TAG POS=1 TYPE=A ATTR=ID:add-discount-code-link
'set the discount code
TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:{{!VAR1}}/admin/discounts ATTR=ID:discount_code CONTENT={{!COL1}}
'set the discount amount
TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:{{!VAR1}}/admin/discounts ATTR=ID:discount_value CONTENT={{!VAR2}}
'set the discount experation date (don't use the calendar popup just set the hidden fireld directly)
TAG POS=1 TYPE=INPUT:HIDDEN FORM=ACTION:{{!VAR1}}/admin/discounts ATTR=ID:discount_ends_at CONTENT={{!VAR3}}
'set the discount use limit
TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:{{!VAR1}}/admin/discounts ATTR=ID:discount_usage_limit CONTENT=1
'create shopify discount code!
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:new-code-form ATTR=NAME:commit&&VALUE:Create<SP>Discount
'wait 3 seconds, to give things time to process before moving to the next one
WAIT SECONDS=3
@daverad
Copy link
Author

daverad commented Oct 13, 2011

updated "click on add a discount code link" code to work with change to shopify promotions page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment