Git Product home page Git Product logo

shopify_app's Introduction

Shopify application generator for Rails 3.2

Description

This gem makes it easy to get a Rails 3.2 app up and running with the Shopify API.

The generator creates a basic SessionsController for authenticating with your shop and a HomeController which displays basic information about your products, orders and articles.

Note: It’s recommended to use this on a new Rails project, so that the generator won’t overwrite/delete some of your files.

Installation

# Add the gem shopify_app to your Gemfile
$ echo "gem 'shopify_app'" >> Gemfile
$ bundle install

Usage

$ rails generate shopify_app your_app_api_key your_app_secret

If you don’t have an API key yet, create a Shopify Partner account at shopify.com/partners and create an app. You can also create test shops once you’re logged in as a partner.

When you create your app in the Shopify Partner Account, set the Application URL to http://localhost:3000/login

You can also create a private application that only works for your shop by visiting YOUR-SHOP.myshopify.com/admin/api

Example

$ rails generate shopify_app edffbb1bb793e2750686e6f4647a384a fed5bb18hde3e2750686e6f4647a781a

This will create a LoginController and a HomeController with their own views.

Set your required API permissions

Before making API requests, your application must state which API permissions it requires from the shop it’s installed in. These requested permissions will be listed on the screen the merchant sees when approving your app to be installed in their shop.

Start by reviewing the documentation on API permission scopes: api.shopify.com/authentication.html

When you know which ones your app will need, add a scope line to the config/initializers/omniauth.rb file.

Example

Make this change to request write access to products and read access to orders:

Rails.application.config.middleware.use OmniAuth::Builder do
    provider :shopify, 
       ShopifyApp.configuration.api_key, 
       ShopifyApp.configuration.secret,
       :scope => "write_products,read_orders",
       :setup => lambda {|env| 
                   params = Rack::Utils.parse_query(env['QUERY_STRING'])
                   site_url = "https://#{params['shop']}"
                   env['omniauth.strategy'].options[:client_options][:site] = site_url
                 }
end

(Note that you can change your API permission scopes on the fly, but the merchant will have to approve each change and your computed API password will change.)

After running the generator

First, start your application:

$ rails server

Now visit localhost:3000 and install your application in a Shopify store.

After your application has been given whatever API permissions you requested by the shop, you’re ready to start experimenting with the Shopify API.

Rails 3.0 (as in before 3.1) Support

Rails 3.0 (as in before the big changes in 3.1) is supported on a branch of our github repo: github.com/Shopify/shopify_app/tree/rails_3.0_support

Questions or problems?

api.shopify.com <= Read up on the possible API calls!

ecommerce.shopify.com/c/shopify-apis-and-technology <= Ask questions!

wiki.shopify.com/Shopify_App_Development <= Edit the docs!

shopify_app's People

Contributors

jnormore avatar jamesmacaulay avatar gauravmc avatar davefp avatar beckwith-zz avatar duncan avatar warrendunlop avatar wvanbergen avatar carolineschnapp avatar dylanahsmith avatar blakemesdag avatar johntajima avatar soleone avatar ssoroka avatar eugenebolshakov avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.