简体   繁体   English

使用shopify_api gem的shopify订单履行问题

[英]shopify order fulfillment issue using shopify_api gem

I have a problem in fulfilling the line item in a order through shopify_api gem. 我在通过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: 以下是有关标头,实现对象和tcpdump的详细信息:

Shopify headers 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"}

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 tcpdump输出

10:07:14.498936 IP localhost.localdomain.34941 > localhost.localdomain.domain: 50737+ AAAA? 10:07:14.498936 IP localhost.localdomain.34941> localhost.localdomain.domain:50737+ AAAA? olson-pfeffer-and-ratke1494.myshopify.com. 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 shops.shopify.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. (160)E ..... @。@。1 ....... X。 :....< 10:07:14.655650 IP localhost.localdomain.36871 > localhost.localdomain.domain: 39864+ A? :.... <10:07:14.655650 IP localhost.localdomain.36871> localhost.localdomain.domain:39864+ A? olson-pfeffer-and-ratke1494.myshopify.com. 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 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 ......@.................................qq.j.............6k.. 10:07:16.338153 IP6 geek-laptop.46193 > geek-laptop.46193: UDP, length 20 ......@.................................qq./#........).....!.6k.. 10:07:16.340185 IP6 geek-laptop.46193 > geek-laptop.46193: UDP, length 16 ......@.................................qq..G..... (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 ....... .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,长度16 ...... @ ... ..................... qq.j ............. 6k..10 :07:16.338153 IP6 geek-laptop.46193> geek-laptop.46193:UDP,长度20 ......@.................................qq./#........).....!.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, length 924 `......@.................................qq.tk........)... ...............................................................................................".......".......f ......................................................................................................................................................................................................c ..................................................................................................2 ..................................................................................................w ..................................................................................................) ..................................................................................................8 .....!。6k .. 10:07:16.350974 IP6 geek-laptop.46193> geek-laptop.46193:UDP,长度924`...... @ .......... ....................... qq.tk ........)... ............ .................................................. .................................“.......“.......F .................................................. .................................................. .................................................. ................................................C 。 .................................................. ............................................... 2 .. .................................................. .................................. w ... .................................................. ..........................................).... .................................................. ............................................ 8

The actual problem is that when you're creating the fulfillment you're passing :params => hash_of_fulfillment_data to the new method. 实际的问题是,当您创建实现时,您:params => hash_of_fulfillment_data传递给new方法。 Just pass the data, you don't need a params key. 只需传递数据,就不需要params键。 This is just standard ActiveResource, nothing special. 这只是标准的ActiveResource,没什么特别的。 This should work: 这应该工作:

f = ShopifyAPI::Fulfillment.new(:order_id => order.id, :line_items =>[ {"id" => order.line_items.first.id} ] )
f.prefix_options = { :order_id => order.id }
f.save

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM