Skip to content

Instantly share code, notes, and snippets.

View n8yeung's full-sized avatar
🎯
Focusing

Nathan Yeung n8yeung

🎯
Focusing
View GitHub Profile
@kevinhughes27
kevinhughes27 / product_update
Created April 3, 2014 16:20
update shopify product inventory with the API
I start by getting the product data from Shopify for the product in question, you might already have this data in your database. Using the Shopify API gem for ruby this looks like:
ruby > product = ShopifyAPI::Product.find(183524354)
which returns the following JSON:
{"body_html":"A Baseball Cap","created_at":"2014-03-14T19:25:19-04:00","handle":"moose","id":183524354,"product_type":"hat","published_at":"2014-03-14T19:25:05-04:00","published_scope":"global","template_suffix":null,"title":"Hat","updated_at":"2014-04-03T12:06:34-04:00","vendor":"kevins_sweet_test_shop","tags":"","variants":[{"barcode":null,"compare_at_price":null,"created_at":"2014-03-14T19:25:19-04:00","fulfillment_service":"manual","grams":0,"id":419761934,"inventory_management":"shopify","inventory_policy":"deny","option1":"Red","option2":null,"option3":null,"position":1,"price":"10.00","product_id":183524354,"requires_shipping":true,"sku":"","taxable":true,"title":"Red","updated_at":"2014-04-03T12:06:34-04:00","inventory_quantity":10,"old