[英]How can filter orders made after a certain date in liquid/ Shopify?
{% for orders in checkout.customer.orders %}
//count the orders
{% endfor %}
我需要計算特定日期之后的訂單嗎? 如何在 Liquid / Shopify 中執行此操作?
所有訂單都有一個created_at
日期,您可以使用Liquid 日期過濾器以各種格式使用 output — 您可以循環遍歷上述訂單,並將其與所討論的“閾值日期”進行比較,使用 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 %}
然后您可以 output {{ ordersCount }}
。
注意:我不認為 Shopify 將允許您分頁超過 50 個訂單。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.