How to get the order ID in the order-received and view-order page?

For my Fancy Product Designer plugin I need to get the order ID in the order-received page and view-order page. Woocommerce offers a filter hook to get the ordered item link:  woocommerce_order_item_name, which is currently not documented in the filter hooks reference. I found it when I browsed through the woocommerce source code. Its located in the order-details.php template. For older version than 2.1 it was woocommerce_order_table_product_title.

Via this filter hook you can change the item link and receive an array that represents the item. The array contains following values:

Let’s see how it looks like when using the filter hook:

For my Fancy Product Designer plugin I need to get the current order ID, in older version it was very easy, because it was appended as GET parameter in the URL, so I could receive it via a simple $_GET request. It’s still available as GET parameter, when default permalinks are used. But for custom permalinks, it’s now shown as path in the URL, e.g. my-account/view-order/398/. I was browsing through the source code of woocommerce and was not thinking that it will be such a tough task to get the order ID, actually I thought woocommerce offers a simple solution to get the order ID of an item, but I could not find any simple solution, so I created this little dirty snippet:

First of all…if anyone has a simpler solution, please let me know via the comments.