Help with preventing or catching a shop fatal error

  • When displaying a list of orders to the customer, I'm encountering a couple of issues:

    1. Deleted orders are still shown to the customer when using:

    'sort' => 'orderID',
    'sort-order' => 'DESC',

    If a deleted order is clicked it returns a fatal error (I've deleted some of the file path info).

    Fatal error: Uncaught Error: Call to a member function to_array() on boolean in /addons/apps/perch_shop/lib/PerchShop_Order.class.php:538 Stack trace: #0 /addons/apps/perch_shop/lib/PerchShop_Order.class.php(393): PerchShop_Order->format_invoice_for_template(Array) #1 /addons/apps/perch_shop/lib/PerchShop_Order.class.php(402): PerchShop_Order->get_for_template() #2 /addons/apps/perch_shop/lib/PerchShop_Runtime.class.php(765): PerchShop_Order->template(Array) #3 /addons/apps/perch_shop/runtime/orders.php(62): PerchShop_Runtime->get_order_items(Array) #4 /templates/pages/shop/account/orders.php(8): perch_shop_order('1', Array, true) #5 /User in /addons/apps/perch_shop/lib/PerchShop_Order.class.php on line 538

    2. If an order contains a product that has since been deleted the same happens (note orders containing deleted products still appear OK in the orders within the admin area).

    Can anyone help?