Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>As David mentioned, your first stop should be the Shopify Wiki. </p> <p>If you're light on actual development experience, this is going to be a little uphill. Start by becoming familiar with one of: Ruby, Python, or PHP. Make sure you know how create basic CRUD-style applications with database connectivity. Ruby is definitely recommended though, because Shopify has an API gem for its web framework, Rails.</p> <p>Once you've got all of the above covered, here's one possible route:</p> <p>The artists' work has to be categorized or divided in some way right? You could be using individual collections, for example. Let's assume that you are, for the sake of an example.</p> <p>So what you need to do is create an interface for choosing specific collections and displaying the sales data associated with those products. You'll need to do four things to accomplish this: (1) Get a list of all collections in the store; (2) Tally the total sales amount for all of the products in each collection, and; (3) Implement an interface for selecting a collection and displaying the sales amount. This is probably the <em>minimum</em> feature set you'll need. </p> <p>So, first you'll need to get a list of all of the collections on the site. Shopify has a method for this, <a href="http://api.shopify.com/customcollection.html" rel="nofollow">Custom Collections</a>:</p> <pre><code>GET /admin/custom_collections.json </code></pre> <p>This will return an array of your custom collections. It'll look something like this:</p> <pre><code>HTTP/1.1 200 OK { "custom_collections": [ { "title": "IPods", "id": 841564295, } ] } </code></pre> <p>So now you've got your array. Each element in the array is a collection - and each collection is associated with a particular artist. Second, we'll need to calculate the sales total for each collection. To do this, we'll need a list of orders:</p> <pre><code>GET /admin/orders.json </code></pre> <p>Each order has a <code>line_items</code> element, which is an array of all of the products on the order. You're going to need to iterate through each of them, check which collection they belong to, and then add the sale value to a collection-specific variable. Unfortunately, Shopify's API doesn't return back the <code>collection_id</code> for a given product. But it does allow you to return a list of products from a given collection.</p> <pre><code>GET /admin/products.json?collection_id=841564295 </code></pre> <p>So you'll need to consume this data from Shopify, create a table in your own database, and then look up the product-specific collection_id's yourself. I'll leave the details of all of that for you to figure out :)</p> <p>But once that's in place, it's relatively straightforward to generate and calculate the running total sales for each collection, just by looping through the products on each order, looking up the their corresponding collections, and then incrementing a collection-specific variable (or database column) with a running total.</p> <p>Finally, you'll need to build a simple web interface to display a tool to select the collection, and then return the calculated total.</p> <p>Now, this won't be the final solution - you're going to have to deal with the API call limit (300 per 10 minutes), performance issues, etc. But if you're persistent, you really <strong>can</strong> do this.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload