Forum
Display purchased item(s) using perch_shop_order()
I am currently using a list/detail setup to display the full details of an order – the order detail page looks like this:
<?php
$order_id = perch_get('orderID');
perch_shop_order($order_id);
?>
Which uses a simple shop/orders/order.html template:
<table class="rtb-table">
<thead>
<tr>
<th>Order ID</th>
<th>Invoice #</th>
<th>Date</th>
<th>Total</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<td><perch:shop id="orderID" /></td>
<td><perch:shop id="invoice_number" /></td>
<td><perch:shop id="orderCreated" type="date" format="F d, Y @ g:ia" /></td>
<td><perch:shop id="grand_total_formatted" /></td>
<td style="text-transform: capitalize"><em><perch:shop id="orderStatus" /></em></td>
</tbody>
</table>
What I would like to do is display further details about the order – namely the items of the order. I can see this data is available to the template (doing a perch:showall) as an array with the id of "items".
Adding <perch:shop id="items" />
to the order.html template simply outputs "Array".
Is it possible to output the values from this array in a way to create a more detailed order receipt? I feel like this answer is a hint – it looks like it makes the items array accessible to the list output – but I can't seem to modify it for my needs (i.e., can't figure out how to output the array values into the template).
Thanks in advance!
Hello Richard,
If you are using
perch_shop_order()
, you should be able to output a list of the ordered items withperch:orderitems
tags:The forum post you mentioned is a solution to output the order details in the customer's orders list via
perch_shop_orders()
Hi Hussein,
Thanks for pointing me in the right direction – not sure how I missed that one, as it's right in the default
shop/orders/items.html
. Cheers!