我在通过 shopify_api gem 完成订单中的订单项时遇到问题。当我履行单个订单项时,它会履行订单中的所有订单项。我已经调查过了,人们说一些关于设置标题的事情,请清除。
我正在做的是
order = ShopifyAPI::Order.find(order_id)
假设此订单有多个订单项
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
这段代码履行订单中的所有行项目,并将履行状态设置为已履行,这是不希望的。
以下是标头、实现对象和 tcpdump 的详细信息:
Shopify 标头
(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"}
履行对象
#<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 输出
10:07:14.498936 IP localhost.localdomain.34941 > localhost.localdomain.domain: 50737+ AAAA?olson-pfeffer-and-ratke1494.myshopify.com。(59) E..W..@.@.D........}.5.CV1............olson-pfeffer-and-ratke1494 myshopify.com ..... 10:07:14.655477 IP localhost.localdomain.domain > localhost.localdomain.34941: 50737 1/1/0 CNAME shop.shopify.com。(160) E....@.@.1........X. :....< 10:07:14.655650 IP localhost.localdomain.36871 > localhost.localdomain.domain: 39864+ A? olson-pfeffer-and-ratke1494.myshopify.com。(59)E..W..@.@.D............5.CV............olson-pfeffer-and-ratke1494 myshopify。 com..... 10:07:14.948404 IP localhost.localdomain.domain > localhost.localdomain.36871:39864 5/4/4 CNAME shop.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............ .
......@.................................q.q../#........).....!.6k..
10:07:16.340185 IP6 geek-laptop.46193 > geek-laptop.46193: UDP, length 16
......@..................................qq..G...... .....!.6k .. 10:07:16.350974 IP6 geek-laptop.46193 > geek-laptop.46193:UDP,长度 924 `......@............ ............ qq.tk............)............ ..................................................... ................................“.......“.......F 。 ..................................................... ..................................................... ..................................................... ...............................................C .. ..................................................... ...................................................2 ... ..................................................... ...................................w .... ..................................................... ..................................................)...... …………………………………………………………………………………………..................................................... .....................8