Created
July 17, 2010 15:38
-
-
Save resistorsoftware/479584 to your computer and use it in GitHub Desktop.
Discount Coupons
This file contains 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
require 'rubygems' | |
require 'mechanize' | |
BASE = 'http://manure.myshopify.com/admin' | |
LOGIN = '/auth/login' | |
USER = '[email protected]' | |
PWD = 'moo-moo' | |
agent = Mechanize.new | |
page = agent.get(BASE+LOGIN) | |
form = page.forms.first | |
form.login = USER | |
form.password = PWD | |
agent.submit(page.forms.first) | |
codes = %w(COW-0 COW-1 COW-2 COW-3 COW-4 COW-5) # make a million codes if you dare | |
page = agent.get(BASE+'/marketing') | |
form = page.forms.each {|e| e['id'] == 'new-code-form'} | |
form = page.forms.first | |
codes.each do |code| | |
form["discount[code]"] = code | |
form["discount[value]"] = '1' | |
form["discount[starts_at]"] = Date.today.strftime('%F') | |
form["discount[ends_at]"] = Date.today.+(10).strftime('%F') | |
form["discount[minimum_order_amount]"] = '0.0' | |
form["discount[usage_limit]"] = '1' | |
form["type"] = 'percentage' | |
form["commit"] = 'Create Discount' | |
r = agent.submit(page.forms.first) | |
pp r | |
end |
Hi,
I am pretty sure that will not work!
I hot-rodded that some time ago to actually work....
I regularily use that code under the hood of an App to generate codes, and I
think I had to change some of it when Shopify changed their codes.. that
being said, you can use Mechanize to do almost anything to a Shop...
Glad you liked..
Dave
…On Tue, Sep 27, 2011 at 3:55 PM, Dave Rapin < ***@***.***>wrote:
Thanks for this.
##
Reply to this email directly or view it on GitHub:
https://gist.github.com/479584
Seems like a good starting point, and that's enough for me.
By the way, here's a working script to load in a bunch of groupon codes.
https://gist.github.com/1246051
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this.