What are some ways to get the current order ID from within a callback function hooked to a WooCommerce filter where the callback is not passed the order ID by default?
Example hook to a WooCommerce filter that meets this criteria:
add_filter('woocommerce_get_downloadable_file_urls', array('fooClass', 'fooFighter'), 10, 4);
This hook passess the following variables to the callback:
- $file_urls
- $product_id
- $variation_id
- $item
I have looked into accessing the order ID through $woocommerce by defining it as a global. In this instance (when WooCommerce sends the customer the completed order email), $woocommerce does not contain a WC_Order object.
For additional information, I am attempting to use the aforementioned hook to create custom download links for specific WooCommerce products. This filter is called each time a downloadable product is listed on the completed order email and again on the order complete page). To create the custom link, I need the order_id.