2017-05-31 85 views
0

我从Shopify API获得了一些非常奇怪的结果,我希望有人能帮助我。Shopify订单API - 传递折扣

我试图创建一个订单,打折。它实际上保存订单,与折扣信息...但数额总是错

order_params = { 
    :browser_ip => webhook[:browser_ip], 
    :buyer_accepts_marketing => webhook[:buyer_accepts_marketing], 
    :currency => webhook[:currency], 
    :email => webhook[:email], 
    :financial_status => webhook[:financial_status], 
    :landing_site => webhook[:landing_site], 
    :note => webhook[:note], 
    :referring_site => webhook[:referring_site], 
    :line_items => line_items, 
    :tag => tags, 
    :transactions => transactions, 
    :discount_codes => webhook[:discount_codes], 
    :total_discounts => webhook[:total_discounts], 
    :shipping_address => webhook[:shipping_address], 
    :shipping_lines => webhook[:shipping_lines], 
    :customer_id => @options[:customer_id], 
    :billing_address => webhook[:billing_address] 
    } 
    @shopify_order = ShopifyAPI::Order.create(order_params) 

正如你可以看到它从webhook数据创建。这是给我回来......(截)

"reference"=>nil, 
"user_id"=>nil, 
"subtotal_price"=>"55.00", 
"total_discounts"=>"55.00", 
"location_id"=>nil, 
"source_identifier"=>nil, 
"source_url"=>nil, 
"processed_at"=>"2017-05-31T15:53:03-04:00", 
"device_id"=>nil, 
"phone"=>nil, 
"browser_ip"=>nil, 
"landing_site_ref"=>nil, 
"order_number"=>1140, 
"discount_codes"=> 
[#<ShopifyAPI::Order::DiscountCode:0x007ffbec42ccb0 
    @attributes={"code"=>"50% OFF", "amount"=>"55.00", "type"=>""}, 
    @persisted=true, 
    @prefix_options={}>] 

到目前为止,那么好所有的数据是正确的..然后我保存这个情况..贴现金额不正确...它应该是£55 。

shopify error

回答

0

我没有挖太深到这一点,但我敢肯定的代码必须是唯一的。

即你可能已经有一个折扣代码50% OFFamount: 60.50在该店铺的其他地方定义。

尝试使用新的独特折扣代码并使用该代码进行测试。

我会建议创建一个新的折扣代码,如50OFF,它有amount: 50type: percentage,那么您可以重复使用那个有50%折扣的订单。

See the Price Rules reference for more information >