我希望能够显示文本‘新’与一个产品,是最近在shopify中添加的。
有点像{% if product.date_added > ten_days_ago %}New{% endif %}
编辑
似乎有一些product的无文档对象,这是我通过控制台日志记录{{ product | json }}发现的。
{{ product.created_at }}
{{ product.published_at }}发布于 2017-06-23 05:14:42
你可以做这样的事。
{% assign product_date = product.published_at | date: "%s" %}
{% assign current_date = 'now' | date: '%s' %}
{% assign difference = current_date | minus: product_date | date: "%d" %}
{% if difference < 10 %}
New
{% endif %}https://stackoverflow.com/questions/44712790
复制相似问题