-
-
Save systembell/a88bf3ce0877ea36640cc5a7c711f940 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Shopify store data widget | |
by Larry Wheeler | |
# Description | |
Widget for [Dashing](http://dashing.io/) that shows data from your Shopify shop. | |
# Usage | |
1. To use this widget, copy `shopify.html`, `shopify.coffee`, and `shopify.scss` into a `/widgets/shopify` directory, and copy the `shopify.rb` file into your `/jobs` folder. | |
2. Create a private app in your store and copy the secret and login. https://docs.shopify.com/api/guides/api-credentials | |
3. Add gem 'shopify_api', :require => 'shopify_api' to your Gemfile 'gem install shopify_api' | |
To include the widget in a dashboard, add the following snippet to the dashboard layout file: | |
```html | |
<li data-row="1" data-col="1" data-sizex="1" data-sizey="1"> | |
<div data-id="shopify" data-view="Shopify" data-title="Shopify" style="background-color:#47bbb3;"></div> | |
<i class="icon-shopping-cart icon-background"></i> | |
</li> | |
``` | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.widget-shopify { | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1 class="title" data-bind="title"></h1> | |
<h4> | |
Open Orders count | |
</h4> | |
<div data-bind="value"></div> | |
<p class="more-info" data-bind="moreinfo"></p> | |
<p class="updated-at" data-bind="updatedAtMessage"></p> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'shopify_api' | |
login = '' | |
secret = '' | |
shop = '' | |
shop_url = "https://" + login + ":" + secret + "@" + shop + ".myshopify.com/admin" | |
ShopifyAPI::Base.site = shop_url | |
shop = ShopifyAPI::Shop.current | |
SCHEDULER.every '30s', :first_in => 0 do |job| | |
# /admin/orders/count.json | |
orderCount = ShopifyAPI::Order.count() | |
send_event('shopify', {value: orderCount}) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment