【问题标题】:Shopify Order API - Passing DiscountShopify 订单 API - 传递折扣
【发布时间】:2017-05-31 20:28:09
【问题描述】:

我从 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


    【解决方案1】:

    我没有深入研究这个,但我很确定代码需要是唯一的。

    即您可能已经有一个折扣码,其代码与 50% OFFamount: 60.50 在该商店的其他地方定义的代码相同。

    尝试使用新的、唯一的折扣代码并进行测试。

    我建议创建一个新的折扣代码,例如 50OFF,其中包含 amount: 50type: percentage,然后您可以将其重新用于具有 50% 折扣的订单。

    See the Price Rules reference for more information >

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-06-26
      • 2023-04-06
      • 2019-03-15
      • 2013-11-09
      • 1970-01-01
      • 2019-08-28
      • 1970-01-01
      相关资源
      最近更新 更多