Forum

Thread tagged as: Question, Shop

Show Shop orders and order items on one page

Hi,

in Perch Shop it is possible to show all orders for the customer by using «perch_shop_orders()». By clicking on a link you can get to the detail page with «perch_shop_order()». I wonder if it’s possible to combine both on one page, e.g.:

Order #1, some text: - Item 1 - Item 2 - ...

Order #2, some text: - Item 1 - Item 2 - ...

Has any one an idea if this is possible using Perch Shop?

Thanks René

Rene Vogt

Rene Vogt 1 points

  • 3 years ago
Hussein Al Hammad

Hussein Al Hammad 105 points
Registered Developer

Hello Rene,

Yes, it is possible. It is basically the same as this: https://docs.grabaperch.com/perch/content/functions/how-do-i-create-list-detail-pages/

Hi Hussein,

thanks for your suggestion.

Actually it’s not what I was looking for as the Customer still have to click on a link to get the order details. I was looking for a combined solution where the customer can see all order items for all orders without choosing an order and getting to a detail page/template (e.g. like on amazon: https://www.ferienspass-ludwigsburg.de/perch/resources/orders.png).

Hussein Al Hammad

Hussein Al Hammad 105 points
Registered Developer

Ok, so you want to add the order details in the list?

You can use an each callback to add the order details. The following calls perch_shop_order() for each item on the list:

perch_shop_orders([
    'each' => function($item) {
        $item['order_details'] = perch_shop_order($item['orderID'], ['template' => 'shop/orders/items_in_list'], true);
        return $item;
    }
]);

And in your listing template:

<perch:shop id="order_details" html="true" />

Hi Hussein,

thanks for your reply. I will test it the next days.

René

Edit:

Hi Hussein, I just tested it and it was exactly what I was looking for :)

Thanks for your help

René