【问题标题】:loop through customers and/or orders in Shopify using liquid code使用流动代码在 Shopify 中循环访问客户和/或订单
【发布时间】:2016-05-31 21:28:52
【问题描述】:

我是流动代码和 shopify 的新手,我想知道是否可以通过客户和/或订单进行循环?

我尝试了下面的代码但没有成功:

{% for customer in customers %}
  {% for order in customer.orders %}
    {{ order.order_number }}
  {% endfor %}
{% endfor %}

{% for order in orders %}
  {{ order.order_number }}
{% endfor %}}

【问题讨论】:

    标签: shopify liquid


    【解决方案1】:

    在 Shopify 中,为了呈现面向客户的商店,您可以使用 Liquid。

    在您提供的 Liquid 示例中,假设存在客户。从客户端的角度来看,这没有任何意义。您只能将单个登录的客户视为:

    {{ customer }} 
    

    当然,假设一个已登录。否则,所有赌注都取消。

    其次,如果您确实有客户,那么您当然可以看到他们的订单。要将所有订单展示给客户,他们的订单,您会得到 ​​p>

    {{ customer.orders }}
    

    因此,假设客户存在并且有订单,您可以遍历客户的这些订单。

    文档很好。 https://help.shopify.com/themes/liquid/objects

    【讨论】:

    • 感谢大卫的回答。
    猜你喜欢
    • 1970-01-01
    • 2017-03-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-26
    • 2016-04-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多