Instantly share code, notes, and snippets.

Embed
What would you like to do?
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://thespicygourmet.myshopify.com
'How much is your discount? for a $15 discount enter 15
SET !VAR2 20
'When does your discount expire? yyyy-mm-dd
SET !VAR3 2011-02-28
'####################### !!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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment