【问题标题】:Shopify Help Returning Line Item PropertiesShopify 帮助退货订单项属性
【发布时间】:2020-06-09 20:06:14
【问题描述】:

我在检索订单的行项目属性时遇到问题。问题是我使用的代码没有显示任何内容。 我能够获取订单行项目,但行项目的属性(例如,如果我有一个表单字段名称 properties[SomeText] 或 properties[Color])

这是我正在使用的简化版本:

{% for item in order.line_items %}
Sku: {{item.item.sku}}
Product Title: {{item.title}}
    {% for prop in item.properties %}
    Properties: {{ prop.first }} = {{ prop.last }}
    {% endfor %}
{% endfor %}

在上面的示例中,Sku 和 Product Title 的值正常工作,但我没有收到任何属性返回的值。我知道它们的存在是因为它们会在我查看订单时显示。

所以,我不确定我做错了什么。任何帮助将不胜感激。

【问题讨论】:

  • 您的代码有效。请仔细检查您的line_items 是否确实具有属性,并且它实际上不是订单属性。
  • 如果我查看订单的 XML:``` ```

标签: ruby shopify shopify-api


【解决方案1】:

查看 Order 的原始 XML 后,我注意到我没有使用 prop.firstprop.last,而是将其更改为 prop.nameprop.value,并且它可以工作。

{% for item in order.line_items %}
Sku: {{item.item.sku}}
Product Title: {{item.title}}
    {% for prop in item.properties %}
    Properties: {{ prop.name }} = {{ prop.value }}
    {% endfor %}
{% endfor %}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-26
    • 1970-01-01
    • 1970-01-01
    • 2018-06-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多