【发布时间】:2019-05-18 15:12:50
【问题描述】:
不是开发人员,只是想一起破解一些东西。在我们的 Shopify 网站中,有一些逻辑可以使用 order.id 标记特定博客中的新博客文章。所以这个博客的帖子每个帖子都有一个 order.id。
在客户记录(帐户)上,我制作了一个网格,我想在其中显示 article.tags 与 customer.orders 匹配的所有文章。
我为所有客户的订单 ID 创建了一个数组,并尝试将此数组与 article.tags 数组进行比较,并仅显示两个数组中匹配的文章。
请帮忙!
这是在 customers/account.liquid 上:
<div class="table-wrap">
<table class="full table--responsive">
<thead>
<tr>
<th>POST NAME</th>
</tr>
</thead>
<tbody>
{% assign myorders = '' %}
{% for order in customer.orders %}
{% capture myorders %}
{{ myorders }} {{ order.id }}
{% endcapture %}
{% endfor %}
{% for article in blogs.my-posts.articles %}
{% if article.tags contains myorders %}
<!--SHOW THE MATCHING ARTICLES HERE-->
<tr>
<td class="underline"><strong><a href="{{ article.url }}">{{ article.title | capitalize }}</a></strong></td>
<tr>
{% else %}
You have no posts.
{% endif %}
{% endfor %}
</tbody>
</table>
</div>
【问题讨论】: