Sendy woudln't be the Mailchimp killer without a proper Shopify integration. There we go, thanks to the Shopify gem and some ActiveRecord awesomeness.
NB: The script always keep in sync Shopify's accepts_marketing field with Sendy's unsubscribed field. I added custom fields like country and order count as an example of what we can do with it.
First make sure that you have the right ruby install (with rbenv for instance), with the right gems installed
(like activerecord
, shopify_api
, etc) and the right mysql packages for the activerecord adapter;
- Put those two files in the same folder, from which you will need to run the script (for instance
/home/ubuntu/tasks/
) - Edit them to match your config
- Make sure you set the right
custom_fields
variable line 30. If you don't have any custom field on your sendy install, make it an empty string.
Simply run ruby shopify_customers.rb
If you want to run this task periodically (e.g. every two hours), you can set up a cron task:
crontab -e
- Add those lines (note that we update the PATH to get the right ruby environment - that one corresponds to a standard rbenv install):
HOME=/home/ubuntu/tasks/
PATH=/home/ubuntu/.rbenv/plugins/ruby-build/bin:/home/ubuntu/.rbenv/shims:/home/ubuntu/.rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
0 */2 * * * ruby shopify_customers.rb > /dev/null 2>&1
This still works in principle. I made a couple modifications for more modern installs of Ruby and Shopify but all of the core ideas from this one still work. As the original poster says, you'll have to have a server you can control with Ruby installed and possibly setup a cron job if you want this to run automatically. My forked version of this script is here: https://gist.github.com/raafirivero/1aeb97d5016e458d82d729f6e50d44e1