【问题标题】:How can filter orders made after a certain date in liquid/ Shopify?如何在 Liquid/Shopify 中过滤特定日期之后的订单?
【发布时间】:2020-03-02 15:38:39
【问题描述】:
{% for orders in checkout.customer.orders %}
//count the orders 
{% endfor %}

我需要计算特定日期之后的订单吗? 如何在 Liquid / Shopify 中执行此操作?

【问题讨论】:

  • 你能告诉我们你到目前为止做了什么吗?

标签: shopify liquid shopify-template


【解决方案1】:

所有订单都有一个created_at 日期,您可以使用Liquid date filter 以各种格式输出 - 您可以通过上述订单循环,并使用 unix 格式将其与所讨论的“阈值日期”进行比较比较日期:

{% assign ordersThresholdUnix = '2019-01-01' | date: '%s' %}
{% assign ordersCount = 0 %}
{% for orders in checkout.customer.orders %}
  {% assign orderDateUnix =  order.created_at | date: '%s' %}
  {% if orderDateUnix > ordersThresholdUnix %}
    {% assign ordersCount = 0 %}
  {% endif %}
{% endfor %}

然后您可以输出{{ ordersCount }}

注意:我不认为 Shopify 将允许您分页超过 50 个订单。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-10-12
    • 1970-01-01
    • 2015-12-10
    • 1970-01-01
    • 2012-09-01
    • 2012-10-27
    • 1970-01-01
    • 2018-04-13
    相关资源
    最近更新 更多