I have a problem in fulfilling the line item in a order through shopify_api gem. When I fulfill a single line item it fulfills all the line items in the order. I have looked into it and people say something about setting headers, please clearify.
What I am doing is
order = ShopifyAPI::Order.find(order_id)
Suppose this order has multiple line items
f = ShopifyAPI::Fulfillment.new(:params => { :order_id => order.id, :line_items => [ {"id" => order.line_items.first.id} ] })
f.prefix_options = { :order_id => order.id }
f.save
This piece of code fulfills all the line items in the order and set the fulfillment status as fulfilled which was not desired.
Below are the details with header, fulfillment object and tcpdump:
Shopify headers
(rdb:1) p ShopifyAPI::Fulfillment.headers
{"User-Agent"=>"ShopifyAPI/3.0.1 ActiveResource/3.1.1 Ruby/1.9.2", "X-Shopify-Access-Token"=>"be9d4adaa35e7f82b720a3567250424c"}
Fulfillment object
#<ShopifyAPI::Fulfillment:0xca2086c @attributes={"params"=>#<ShopifyAPI::Fulfillment::Params:0xca20b00 @attributes={"order_id"=>138494648, "notify_customer"=>true, "tracking_number"=>"12345678", "line_items"=>[#<ShopifyAPI::LineItem:0xca28904 @attributes={"id"=>225568082}, @prefix_options={}, @persisted=false>]}, @prefix_options={}, @persisted=false>}, @prefix_options={:order_id=>138494648}, @persisted=false>
tcpdump output
10:07:14.498936 IP localhost.localdomain.34941 > localhost.localdomain.domain: 50737+ AAAA? olson-pfeffer-and-ratke1494.myshopify.com. (59)
E..W..@[email protected]..........}.5.C.V.1...........olson-pfeffer-and-ratke1494 myshopify.com.....
10:07:14.655477 IP localhost.localdomain.domain > localhost.localdomain.34941: 50737 1/1/0 CNAME shops.shopify.com. (160)
E.....@[email protected]. :....<
10:07:14.655650 IP localhost.localdomain.36871 > localhost.localdomain.domain: 39864+ A? olson-pfeffer-and-ratke1494.myshopify.com. (59)
E..W..@[email protected] myshopify.com.....
10:07:14.948404 IP localhost.localdomain.domain > localhost.localdomain.36871: 39864 5/4/4 CNAME shops.shopify.com., A 204.93.213.40, A 204.93.213.41, A 204.93.213.42, A 204.93.213.44 (301)
E..I..@.@.;..........5...5.H.............olson-pfeffer-and-ratke1494 myshopify.com..............X...shops.shopify.2.G.......X...].(.G.......X...].).G.......X...].*.G.......X...].,.M...........ns3.p19.dynect.net..M...........ns4...M...........ns1...M...........ns2..........0....NF.................0....NG.........0....
10:07:16.326985 IP6 geek-laptop.46193 > geek-laptop.46193: UDP, length 16
[email protected]..
10:07:16.338153 IP6 geek-laptop.46193 > geek-laptop.46193: UDP, length 20
[email protected]../#........).....!.6k..
10:07:16.340185 IP6 geek-laptop.46193 > geek-laptop.46193: UDP, length 16
[email protected]..........!.6k..
10:07:16.350974 IP6 geek-laptop.46193 > geek-laptop.46193: UDP, length 924
`[email protected]........)... ...............................................................................................".......".......f
......................................................................................................................................................................................................c
..................................................................................................2
..................................................................................................w
..................................................................................................)
..................................................................................................8