Shopify App Development for Vendors
I have now successfully deployed and tested over 15 kinds of Shopify App systems to support various clients. The pattern I have adopted has grown more stable and flexible as I continuously experiment with the basics.
Sinatra is my favourite Ruby framework for many reasons. It is very easy to create Domain Specific Languages (DSL) processing, which is perfect for Shopify Apps. It handles models and Active Record well, has support for my favourite template system in Haml and comes in a small but very extensible package of only 2500 lines of code. Compare that to popular Rails, at 250,000 lines of code.
I run Sinatra using the thin webserver on Heroku, one the best cloud-based hosting companies I have ever worked with. Heroku accept an entire App codebase as a simple git remote, and so I can simply git push an entire App to see the magic in action.
A common request from Shopify store owners is to have some sort of external access whereby a third party, a Vendor perhaps, can login to a web application, participate in some aspect of Shopify and yet not have access to the Shopify site itself. I addressed this with an App recently.
Using Sinatra, and Rack, I setup three Applications in the one App, which for this blog we can simply name VendorApp.
VendorApp encapsulates three smaller specialized applications. ShopifyApp, PublicApp and AdminApp. These would be available at three separate URLs.
-
http://vendorapp.heroku.com/ is the way the public (external vendors) login and see their reports, upload their desired products, etc.
-
http://vendorapp.heroku.com/admin is where the Shopkeeper logs in and determines what his vendors can see, what they have been doing, etc.
-
http://vendorapp.heroku.com/shopify is where the ShopifyAPI lives and this is where sales reports can be tallied, orders filtered, products added etc.
Using Warden for Authentication, we can ensure vendors that try the PublicApp login can see only their sales, only their products, etc. With the same code we can also authenticate for access to the AdminApp, where the shopkeeper sees all his Vendors, all their products etc. The admin can control these accounts with a few clicks.
A simple sample workflow for this Application is as follows. Every product has a Vendor. So when an Order is paid for, using a Webhook, we capture the order, and extract the products and vendors. If the Vendor exists we add the quantity and price of the sold product to the Vendor Sales. A vendor has many sales. Now, when the Vendor logs in to the PublicApp, we show them how many products they have sold, and how much money they earned. The Shopkeeper can set a percentage for the Sales, so that a Vendor may see 30% of any Sales.
If you have any interest in this kind of App, drop me a line and perhaps I can install a version of this App into your Shopify store.