Skip to content

Instantly share code, notes, and snippets.

@systembell
Forked from myjanky/Shopify data Dashing
Created March 11, 2024 17:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save systembell/a88bf3ce0877ea36640cc5a7c711f940 to your computer and use it in GitHub Desktop.
Save systembell/a88bf3ce0877ea36640cc5a7c711f940 to your computer and use it in GitHub Desktop.
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>
```
.widget-shopify {
}
<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>
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