有没有办法在Shopify中创建一个以前订购过的商品列表,以及图片?基本上,我正在寻找的是3个项目之前购买的用户在首页上的列表。
发布于 2013-03-13 05:29:34
用户需要登录才能执行以下操作。如果用户已经登录,那么您可以使用以下代码来显示他们的订单。这将仅显示3个订单。
{% if customer.orders.size != 0 %}
<table>
<thead>
<tr>
<th class="order_number">Order</th>
<th class="date">Date</th>
<th class="payment_status">Payment Status</th>
<th class="fulfillment_status">Fulfillment Status</th>
<th class="total">Total</th>
</tr>
</thead>
<tbody>
{% for order in customer.orders limit:3 %}
<tr class="{% cycle 'odd', 'even' %} {% if order.cancelled %}cancelled_order{% endif %}">
<td>{{ order.name | link_to: order.customer_url }}</td>
<td><span class="note">{{ order.created_at | date: "%b %d, %Y" }}</span></td>
<td><span class="status_{{ order.financial_status }}">{{ order.financial_status }}</span></td>
<td><span class="status_{{ order.fulfillment_status }}">{{ order.fulfillment_status }}</span></td>
<td><span class="total money">{{ order.total_price | money }}</span></td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p>You haven't placed any orders yet.</p>
{% endif %}发布于 2013-03-12 10:06:20
当客户登录时,将有一个customer liquid变量可用,其中包含有关用户的大量数据。如果您浏览一下docs,就会发现有一个名为order的成员变量,它将为您提供一个包含所有用户订单的数组。还有一个名为recent_order的变量,它将为您提供用户最近的订单。
如果你熟悉Shopify使用的Liquid模板语言,这应该足以让你入门。一般来说,Shopify wiki是非常有用的。
https://stackoverflow.com/questions/15347300
复制相似问题