Skip to content

Instantly share code, notes, and snippets.

@afeld
Created April 13, 2014 18:35
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 afeld/10596298 to your computer and use it in GitHub Desktop.
Save afeld/10596298 to your computer and use it in GitHub Desktop.
Shopify note_attributes not saving
order = ShopifyAPI::Order.new
order.line_items = [{
:quantity => 1,
:product_id => 222,
:variant_id => 333
}]
# as a JSON object
order.note_attributes = [{:foo => 'bar'}]
order.save!
order.reload
puts order.note_attributes.inspect
# => []
order = ShopifyAPI::Order.new
order.line_items = [{
:quantity => 1,
:product_id => 222,
:variant_id => 333
}]
# as a stringified JSON object, per the documentation
# http://docs.shopify.com/api/order
order.note_attributes = [{:foo => 'bar'}].to_json
order.save!
order.reload
puts order.note_attributes.inspect
# => []
order = ShopifyAPI::Order.new
order.line_items = [{
:quantity => 1,
:product_id => 222,
:variant_id => 333
}]
order.save!
# as a JSON object
order.note_attributes = [{:foo => 'bar'}]
order.save!
order.reload
puts order.note_attributes.inspect
# => []
order = ShopifyAPI::Order.new
order.line_items = [{
:quantity => 1,
:product_id => 222,
:variant_id => 333
}]
order.save!
# as a stringified JSON object, per the documentation
# http://docs.shopify.com/api/order
order.note_attributes = [{:foo => 'bar'}].to_json
order.save!
order.reload
puts order.note_attributes.inspect
# => []
{
"order": {
"line_items": [{
"fulfillment_service": "manual",
"fulfillment_status": null,
"grams": 0,
"id": 111,
"price": "0.00",
"product_id": 222,
"quantity": 1,
"requires_shipping": true,
"sku": null,
"taxable": true,
"title": "Placeholder Product",
"variant_id": 333,
"variant_title": null,
"vendor": null,
"name": "Placeholder Product",
"variant_inventory_management": null,
"properties": [],
"product_exists": true,
"tax_lines": []
}],
"id": 444,
"buyer_accepts_marketing": false,
"cancel_reason": null,
"cancelled_at": null,
"cart_token": null,
"checkout_token": null,
"closed_at": null,
"confirmed": true,
"created_at": "2014-04-13T14:30:00-04:00",
"currency": "USD",
"email": "",
"financial_status": "paid",
"fulfillment_status": null,
"gateway": "",
"landing_site": null,
"location_id": null,
"name": "#1032",
"note": null,
"number": 32,
"reference": null,
"referring_site": null,
"source": "api",
"source_identifier": null,
"source_name": "api",
"source_url": null,
"subtotal_price": "0.00",
"taxes_included": false,
"test": false,
"token": "...",
"total_discounts": "0.00",
"total_line_items_price": "0.00",
"total_price": "0.00",
"total_price_usd": "0.00",
"total_tax": "0.00",
"total_weight": 0,
"updated_at": "2014-04-13T14:30:00-04:00",
"user_id": null,
"browser_ip": null,
"landing_site_ref": null,
"order_number": 1032,
"discount_codes": [],
"note_attributes": "[{\"foo\":\"bar\"}]",
"processing_method": "",
"checkout_id": null,
"tax_lines": [],
"tags": "",
"shipping_lines": [],
"fulfillments": []
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment