How To Create Custom Shopify App With Rails?
Shopify is a custom ecommerce platform that enables companies to build an online store. It is one of the most used platforms for building an ecommerce website. Statistics suggest that over 400,000 websites use Shopify as their ecommerce platform. You can install tons of apps and plugins to add features and functions to the store.
Today, Shopify has become a leading platform for companies all over the world. It is a flexible platform that offers complete customization capabilities. The platform is inexpensive and doesn’t require a lot of technical expertise to build an online store. You can get started with your Shopify store within 48 hours. By hiring a professional SHopify app development company, you can begin with your ecommerce project without any hassle.
Why build a Shopify Application in Rails?
Integrating Shopify in Rails application is a challenge for companies. Shopify Rails application enables rapid development of any ecommerce store. By installing tons of plugins and applications of your choice, you can build a feature-rich store with high functionalities. Rails is a flexible platform with clear and precise code that offers amazing simplicity. Due to that, most companies prefer the Shopify ecommerce app development platform for their websites.
Shopify store owners need more powerful features, services and plugins to customize their store’s workflow for boosting the sales and managing the store workflow. There are large number of apps available on Shopify’s App store in different categories to enhance the Store.
Creating an app for shopify using Ruby on Rails is very easy as Shopify itself is built on Ruby on Rails.
Before starting this tutorial, I assume that you have basic understanding of Shopify and how to create store on Shopify.
Let’s create a Shopify application which will consume Shopify’s REST API to access store and manage store details.
- Create your Shopify partner account first.
- Go to Apps after login into partner’s account. See Image below
Now click Create app and fill up the required details like application name and application URL. You can use your local server (http://localhost:3000) during application development.
Go to App info tab to get an API credentials.
To create a development application, set the Application Callback URL to http://localhost:3000/ and the redirect_uri to http://localhost:3000/auth/shopify/callback See below image.
Now create a new Rails application and add following get to Gemfile.
This gem adds a full Shopify API Application environment to your application. Now bundle to install the newly added gem.
$ bundle install
shopify_app provide a generator to create required artefacts to work with Shopify. Run following command to generate the same
rails generate shopify_app - api_key <your_api_key> - secret <your_app_secret>
You can get your API key and secret from App info tab
If you are not creating an embedded app for shopify then change following in
config.embedded_app = false
In the same file you can change scope configurations as per your requirement and usage of application.
Run Database migration.
$ rake db:migrate
Integration with Shopify is complete. Now start your application server now.
To install your unpublished application to your store follow below steps
1. Click on the Create App Store listing button. See image below.
2. Fill up the details if you want and click on Save button. See image.
3. Once you save the details, you will be redirected to same page and then click on View App listing button just above the ‘Save’ button.
You should see your application in App Store. Which is unpublished yet. Click Get button on right side. See below image.
Make sure that your application is running on server which you set in Shopify application. When you install the application it will redirect to your store. It will ask you for authorization based on the scope which you defined in your initializer file of Shopify App.
Once you authorize the application you will get the token which you can use next time to make REST API calls to access store details so store them safely.
shopify_app> gem saves this shop details by default into Shop model so no need to do that manually.
On your Shopify store within Apps listing you should be able see the installed unpublished application.
Please note that if you make any changes to the application then you have to reinstall application to get those changes changes.
Bingo! Your integration of Shopify application with store using Rails is completed. Now you can check shopify_api gem to access shopify stores.
Have a Happy coding!
At BoTree Technologies, we build enterprise applications with our RoR team of 25+ engineers.
Consulting is free – let us help you grow!
Choose Your Language
- Digital Marketing
- IT Consulting
- Project Management
- Salesforce Development