So you set up a login resource and customers are checking out. Now, you want your customers to be able of seeing their past orders.
Commerce comes with 2 snippets to help you do that.
- commerce.get_orders is used to list a collection of orders.
- commerce.get_order is used to view a single order
Both snippets have access to all the order information. This gives you two options:
- Create a list of orders with the
get_orderssnippet, link those orders to a different order detail resource that has the
- Create an accordion-style order list with just the
get_orderssnippet, where all information is loaded on the same resource.
Basic setup (Orders + separate Order Detail)
On an Orders resource, add
[[!commerce.get_orders]] to the content or its template. This will show a simple table with orders.
To add pagination, you can use getPage or pdoPage, for example:
[[!getPage? &element=`commerce.get_orders` &limit=`10`]] [[!+page.nav]]
commerce.orders_resource system setting with the ID of the orders resource.
On an Order Detail resource, add
[[!commerce.get_order]] to the content or its template. This will look at the
order request parameter to determine what order to show.
commerce.order_resource system setting with the ID of the order detail resource.
This should give you a simple, but functional, order view.
Basic setup (Orders with included Order Detail)
To show order details within the same page, you'll need to provide a custom template that shows the order information you'd like to show.
This could be used to create a nice accordion-style orders page, where clicking a table row will expand it to show the purchased items, address information, etc.