Created
December 19, 2011 14:03
-
-
Save netzpirat/1497369 to your computer and use it in GitHub Desktop.
Create promotion code per collection for Shopify
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Save your promotion codes in code.csv | |
require 'capybara' | |
require 'csv' | |
session = Capybara::Session.new(:selenium) | |
session.visit 'https://YOURSHOP.myshopify.com/admin/auth/login' | |
session.fill_in 'login', :with => 'YOURLOGIN' | |
session.fill_in 'password', :with => 'YOURPASSWORD' | |
session.click_button 'Sign In' | |
session.click_link 'Promotions' | |
CSV.read('codes.csv').flatten.each do |code| | |
session.click_link 'Add a discount code' | |
session.fill_in 'discount[code]', :with => code | |
session.fill_in 'discount[value]', :with => 'YOUR_DISCOUNT' | |
session.select 'collection', :from => 'discount[applies_to_type]' | |
session.select 'YOUR_COLLECTION', :from => 'discount[applies_to_id]' | |
session.click_link 'infinite number of discount codes' | |
session.fill_in 'discount[usage_limit]', :with => '1' | |
session.click_button 'Create discount' | |
sleep 1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment