Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Shopify Application Development
Shopify Application Development

Shopify Application Development: Build highly effective Shopify apps using the powerful Ruby on Rails framework

eBook
$9.99 $19.99
Paperback
$32.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Table of content icon View table of contents Preview book icon Preview Book

Shopify Application Development

Chapter 1. Getting Started with Shopify

Shopify is a Software as a Service (SaaS) e-commerce platform built to meet the needs of the typical storeowner. It offers hosting, shopping cart, payment processing, order management, product catalogs, blogging, and much more. A storeowner can sign up for Shopify, pick out a design, create a product catalog, set up a payment gateway, and make a sale on the same day—all without any programming or technical expertise.

Shopify gives you the ability to completely modify the HTML, CSS, and JavaScript of the storefront theme. Designers are able to add features such as visual effects, responsive designs, bundled products, shipping estimators, and social plugins that can accomplish almost everything that is expected of a modern e-commerce site.

For features such as inventory management, accounting, drop shipping, mailing lists, and, reporting, an application that communicates with Shopify's API and/or handles Shopify's XML notifications (called webhooks) is needed. In this book, we'll focus on building such an app. You should have an understanding of web development using a server-side language such as Ruby, PHP, or ASP.NET. Basic HTML, CSS, and JavaScript skills are also required because we'll be building a simple UI. Finally, familiarity with Shopify's features will be extremely helpful. If you've not used Shopify before, I encourage you to go through this excellent primer on the Shopify blog at http://www.shopify.com/technology/3671962-developing-shopify-apps-part-1-the-setup.

Throughout the course of this book, we will be building a web application that allows the storeowners to run contests by randomly picking a customer who has placed an order in the shop. Our app will be built using Ruby on Rails (http://rubyonrails.org), which is an open source web development framework that is relatively simple to learn. It is the same language that Shopify has been written in. A few popular Ruby libraries (for example, Active Merchant and Liquid) are extractions of the Shopify source code that have been released as open source. Rails is based on the Model-View-Controller (MVC) enterprise architecture pattern, so if you aren't familiar with this paradigm, I encourage you to head over to Wikipedia for a general overview (http://en.wikipedia.org/wiki/Model–view–controller).

This chapter will cover the following topics:

  • An overview of the Shopify platform

  • App development options

  • The Shopify API

  • The Shopify Webhook system

  • Tips on how to get started

Revealing Shopify's power


Shopify offers a comprehensive e-commerce solution designed to meet the needs of a typical storeowner who wants to sell products online. The theme gallery, extensive wiki, and active forum provide an excellent end-to-end experience even for the most inexperienced computer user. For customers who need more personalized support, there is the Shopify Experts directory, which is a great place to find a designer, programmer, or setup expert.

Two features, the robust API (http://docs.shopify.com/api) and the App Store (http://apps.shopify.com), put Shopify ahead of the curve compared to its competitors. Rather than trying to include every imaginable feature for every possible line of business, Shopify focuses on the common needs of every storeowner and leaves the rest to the theme customization and apps.

A third feature called webhooks (http://docs.shopify.com/api/webhook) allows apps to receive near real-time notifications of events that take place in a shop. These events range from order creation, product updates, customer signup, to account cancellation. The notifications come in both XML and JSON formats and typical mirror the schema of the API which makes integration a breeze.

Deciding which type of app to build


When it comes to building an app for Shopify, there are two options: private and public. Private applications are designed to access one Shopify store, and can be changed as per the needs of the storeowner by the developer. Public applications are designed to access multiple Shopify stores, and provide functionality that will be used by different types of businesses. They can act as a revenue stream for the developer by charging storeowners a monthly fee.

Both private and public apps perform operations by using the Shopify API and/or by processing Shopify Webhooks. At a high level, a public application can be thought of as a private application that was expanded to work with multiple stores.

To determine which one you need to build, take a look at the following scenarios:

Scenario 1

  • You have a client Shopify store that needs additional functionality

  • You have already determined that what they need is not included in the Shopify out of the box

  • You've looked through the App Store and determined that there isn't an app that meets their needs

  • They aren't interested in reselling the idea to other storeowners, or they don't want competitors to have this functionality

Note

What you are looking to build is a private app. This is an app that is not listed in the official App Store and typically only connects to a single Shopify account.

Scenario 2

  • You or your client have a great idea for an app

  • Other storeowners would benefit from the app and may even pay money to use it

  • You've already checked the App Store and determined that the app doesn't already exist, or that it exists but you think you can improve the idea

Note

What you are looking to build is a public app. This is an application that can access multiple stores and that is listed in the App Store. It can be installed automatically by storeowners.

Discovering the API


Shopify offers an extensive API that allows developers to perform almost any task that can be done via the web admin (and a few that don't like working with Metafields). The full documentation is available at http://api.shopify.com.

The API is RESTful and supports HTTP, JSON, and XML requests. There are several free software libraries available for most of the popular web development languages to help people get started. The libraries are actively supported either by Shopify or the open source community.

In this book, we will only be scratching the surface of the API by focusing on the areas of order retrieval, product management, and application charges. The API allows you to do much more—from modifying the store's themes, setting up shipping charges, to retrieving information about abandoned carts in order to follow up with the shopper.

We'll be working with the following API verticals:

  • Application charge

  • Product

  • Order

  • Webhook

Exploring webhooks


Shopify allows applications to subscribe to a series of notifications called webhooks (http://docs.shopify.com/api/webhook) around common events such as order placement, product updates, and customer signup. Real-world events are mapped to topics that can be subscribed to via the API or by manual setup in the Shopify admin panel. The webhook notification mirrors the format of the API, which makes the implementation code reusable. When an event occurs, Shopify automatically sends the notification to all subscribers.

Orders

Order webhooks allow apps to respond in a near real-time fashion when an order is placed or updated in the Shopify store. The following two events are the most commonly subscribed topics that deal with the creation and payment of an Order:

  • orders/create

  • orders/paid

Products

Product webhooks can be handy for apps that handle inventory, product feeds, or back office integrations. The following three events are of interest when dealing with Products:

  • products/create

  • products/update

  • products/delete

Shop/Application

It will be helpful to automatically reflect any updates to a shop's name, URL, and so on in your app. Likewise, it's polite to suspend/cancel a user's account if they uninstall the app from their store. The following two events allow us to do that:

  • shop/update

  • app/uninstall

Webhooks are sent asynchronously after the event occurs. This makes them suitable for near real-time actions and allows an application to process information in smaller chunks, which can reduce the load and improve performance.

Tip

I also recommend using the API to retrieve information as a backup in case the webhook system gets bogged down or a notification is missed.

For public applications, the webhook for uninstalling the application should be subscribed to so that you can automatically suspend the client's account when they remove your app from their Shopify store.

Getting ready to build an app


If you've decided that you need to build an app, then the next step is to ask yourself the following questions:

  • What exactly does the app need to do?

  • Will the app be private or public?

  • Who will be developing the app?

  • Who will be designing the UI?

  • What is the budget and timeline?

Once you've answered these questions, you should have a rough idea of the big pieces involved in creating the app. The set of features required to build a software is often referred to as the scope.

Determining an application's scope even at a high level is a skill that requires practice. This typically starts as a document that lists the overall purpose, feature list, integration points with Shopify (if known), dependencies on external services or software libraries, proprietary business logic, architectural decisions (language, platform, server requirements, and so on), budget, timeframe, and anything else that will impact the application life cycle.

Creating in-depth specs is beyond the scope of this book, though in general more information at this phase is better (it's easier to trim features and defer them at a later phase as development progresses rather than trying to cram in new ones that were forgotten in the beginning).

At the very least, a list of must-have features is necessary. Even if you are doing the development yourself and the feature set is small, it's a good skill to learn and will often reveal aspects and features that weren't originally planned. This is the technique we'll be using throughout this book. We are going to list out the high-level features that we want to build and turn each one into a sprint. A sprint is an agile methodology term that denotes a discrete amount of work. Usually, a sprint lasts for two weeks or less. In our case, each sprint will last only a few hours because our feature set is simple.

For a larger app, the simplest way to start is to list out all the features, prioritize them, and then set a cutoff based on time and budget. Even if it never progresses beyond a simple list, you'll have something to measure progress against while the app is being developed. Without this list, all the features (complete and pending) will only be in your head.

An analogy for this would be going to the grocery store without a list. Chances are, most of the things you need will end up in the cart, but undoubtedly, you'll either forget a few things (feature deficiency), spend excess time roaming the aisles trying to remember what you need by seeing something you forgot on the shelf (inefficient development/refactoring), or add things that aren't on the list (scope creep). The worst situation to be in is to have all the ingredients to make lunch tomorrow but be unable to make dinner tonight because you forgot something important!

Summary


In this chapter, we looked at some of the features available in Shopify as well as the difference between private and public applications. Then we briefly discussed the Shopify API and webhook system before finishing up with some thoughts on software development and how to get started planning your own app for fun and profit.

During the course of this book, we will be developing a simple app that will allow storeowners to run contests. The app will pick a winner from the list of customers who have made a purchase at the store within a certain timeframe or for a certain product.

The next chapter will cover setting up your local development environment, installing Ruby on Rails, creating a basic app, and deploying it to Heroku (http://www.heroku.com) for cloud hosting. This application will be iteratively expanded in each chapter as we progress towards our goal of publishing it in the Shopify App Store.

Left arrow icon Right arrow icon

What you will learn

  • Create your own multitenant app using Ruby on Rails and deploy it to Heroku
  • Use RSpec and FactoryGirl for TDD
  • Ensure functional and targeted code using iterative development
  • Implement responsive design using Twitter Bootstrap
  • Request and process Shopify API access requests
  • Subscribe, verify, and respond to Shopify Webhooks
  • Publish your app to the Shopify App Store
Estimated delivery fee Deliver to Thailand

Standard delivery 10 - 13 business days

$8.95

Premium delivery 5 - 8 business days

$45.95
(Includes tracking information)

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : May 26, 2014
Length: 106 pages
Edition :
Language : English
ISBN-13 : 9781783281053
Concepts :

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Estimated delivery fee Deliver to Thailand

Standard delivery 10 - 13 business days

$8.95

Premium delivery 5 - 8 business days

$45.95
(Includes tracking information)

Product Details

Publication date : May 26, 2014
Length: 106 pages
Edition :
Language : English
ISBN-13 : 9781783281053
Concepts :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $ 103.97
Shopify Application Development
$32.99
Magento 2 Development Quick Start Guide
$28.99
Shopify Theme Customization with Liquid
$41.99
Total $ 103.97 Stars icon
Banner background image

Table of Contents

5 Chapters
Getting Started with Shopify Chevron down icon Chevron up icon
Setting Up Chevron down icon Chevron up icon
Building a Private App Chevron down icon Chevron up icon
Going Public Chevron down icon Chevron up icon
App Billing and Publication Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.1
(9 Ratings)
5 star 33.3%
4 star 11.1%
3 star 11.1%
2 star 22.2%
1 star 22.2%
Filter icon Filter
Top Reviews

Filter reviews by




Pj Marshall Jun 30, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Really good if you know a bit already, I would much prefer a video tutorial though, I would buy it straight away !
Amazon Verified review Amazon
Robert Daniels Dec 28, 2014
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Working through this book during my winter break, I'm really enjoying the writing style and methodology. This book not only shows you how to build a Shopify App, but it also gives you the proper Rails workflow using Git, Github, Heroku, Rspec and Guard. Support publications should be downloaded from the author's Github account, not PacketPub.
Amazon Verified review Amazon
Curt H. Aug 28, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Very detailed and Technical about using Shopify themes
Amazon Verified review Amazon
Jim Rothfork Mar 27, 2016
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
I've been working my way through and while the book is aimed more at beginners, it feels like it answers a need that's currently absent in the Shopify app development community: clear, concise examples & documentation about how to build an app using Ruby on Rails. I haven't found anything else like it and while I'm not a newbie to coding, web frameworks are something I've not had experience with and this book is filling in a lot of gaps in my knowledge.
Amazon Verified review Amazon
B. Bergman Aug 03, 2014
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
I would have to say that this book is mediocre at best. It seemed like a great start at first, but I found myself skipping over the first several chapters as being completely redundant and not helpful. I suppose for a complete newbie to Ruby or Ruby on Rails, there might be a need for those first few chapters, but I don't think the target audience for this book is the complete newb (I could be wrong). If you're going to work in Ruby, you have to have some basic understanding of the language, and how apps are developed, before you can dive into something like Shopify and expect it to work. After all, this is NOT a WYSIWYG type of tool -- it requires setup, configuration, tailoring, deploying and so on. A new Ruby convert probably won't just pick up this book and start with it.If you skip over a number of the first few chapters, then you're left with the meat of the book. In this instance, the topic is at least useful. The author goes into the basics of Shopify development, including an understanding of what it is, how it can be used, and what you need to do. Half way through the book, I finally felt like I was getting to the good stuff. Unfortunately, the good stuff didn't last long. The rest of the chapters were helpful, but only covered some basics.I wanted to like this book. Although I don't have a pressing need for Shopify, I was curious about it and wanted to learn more. As a Rubyist, I'm always interested in frameworks and applications that use Ruby. From that perspective, the book seemed like what I was looking for. I would say it only satisfied about half of my need, though. The second half was decent, but short. If you're going to spend so much time going into the basics of Ruby and Ruby applications, then at least put 2/3 of the meaty content following it. Right now I only got a taster, and it wasn't enough to be truly helpful. I suppose if you're just looking to dip your feet in the water, or you DO have very limited knowledge of Ruby, then this would be a good starting point. Otherwise, I'd probably recommend finding a different resource.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela