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
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
- Edit them to match your config
- Make sure you set the right
custom_fieldsvariable line 30. If you don't have any custom field on your sendy install, make it an empty string.
If you want to run this task periodically (e.g. every two hours), you can set up a cron task:
- 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