【问题标题】:Passing discount code in Orders API on Shopify在 Shopify 上的 Orders API 中传递折扣码
【发布时间】:2016-10-15 06:17:57
【问题描述】:

我一直在尝试开发一款在 Shopify 上通过不同渠道接受订单的应用。我通过 API 成功下订单,但我无法在订单中包含折扣代码。 POST 数据的 JSON 对象如下:

{
  order: {
    email : request.params.order.email,    // string
    financial_status : 'pending',          // string
    send_receipt : true,                   // boolean 
    send_fulfillment_receipt : false,      // boolean
    note : request.params.order.note,      // string

    discount_codes : [], // supposed to be an array of Object| Problem here,

    line_items : request.params.order.line_items, // array
    customer : request.params.customer,    // JSON object 
    billing_address : request.params.order.billing_address,    // JSON object
    shipping_address : request.params.order.shipping_address   // JSON object
  }
}

根据文档,discount_codes 是这样的 -

Applicable discount codes that can be applied to the order. If no codes exist the value will default to blank. A Discount code will include the following fields: 

amount: The amount of the discount.
code: The discount code.
type: The type of discount. Can be one of : "percentage", "shipping", "fixed_amount" (default).

我做错了什么?我的 discount_codes 是这个

[{amount: 100,code:'WELCOME10',type:'percentage'}]

以前有人做过吗?

【问题讨论】:

  • 请同时提供正在发送的实际 discunt_code(在评估变量之后)
  • [{amount: 100,code:'WELCOME10',type:'percentage'}]

标签: rest post shopify


【解决方案1】:

根据这个response from Shopify,只有当您传递total_discounts 字段以及您要申请的折扣总额时,您才能尝试做的事情。

正如您将在其他 answer 中看到的那样,您通过 Shopify 创建的任何代码都不能用于 API,并且不会记录它们的使用情况。

我试图使用此 API 来测试我生成的不同优惠券代码的应用,但这似乎是不可能的。显然,该 API 旨在应用自定义折扣,而不是 Shopify 中已经存在的折扣。这对我来说是一个令人沮丧的限制。

【讨论】:

    【解决方案2】:

    我一直成功创建带有折扣的订单,没有 ShopifyPlus,因为这无关紧要。适合我的数据结构如下所示:

     [ { "code": "Shop By PizzleFuzzle 10%", amount: "10", "type": "percentage" } ]
    

    【讨论】:

    • 金额“10”是否与“百分比”相关联,而不是购物车中的实际折扣?
    • 创建一个带有 10% 折扣代码的订单。
    • 抱歉回复延迟,生病了。所以是的,代码对我不起作用。我猜只是有些不对劲。无论哪种方式,Shopify 都为我推出了一项新功能,而不是一起使用这种自定义付款。感谢@David Lazar 的帮助..
    • 你说的是什么新功能?
    • 基于规则的货到付款结帐选项。
    【解决方案3】:

    折扣对象仅适用于 Shopify Plus 商家。

    一旦您成为 Shopify Plus 商家,您就可以创建这样的折扣代码:

    POST /admin/discounts.json
    {
      "discount": {
        "discount_type": "percentage",
        "value": "15.0",
        "code": "balderdash"
      }
    }
    

    请在 Shopify API 的折扣对象中查看更详细的文档:https://help.shopify.com/api/reference/discount

    【讨论】:

    • 我明白这一点。但我在 Orders.json 上发布它,对吗?而且它带有一个已经存在的折扣代码。
    【解决方案4】:

    您应该使用 value 属性名称而不是 amount 属性名称。

    例如

    {value: 100,code:'WELCOME10',type:'percentage'}
    

    而不是

    {amount: 100,code:'WELCOME10',type:'percentage'}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-11-09
      • 1970-01-01
      • 1970-01-01
      • 2015-07-07
      • 2013-06-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多