Is there a woocommerce function that will return me all related orders (at least the order identifier) for a specific subscription that the user has?
I found in this official documentation the Subscription Function and the property link :
WC_Subscription::get_related_orders( $return_fields, $order_type );
But this does not look like a specific subscription?
When I try to run it, I get the no mater fatal error that I went through:
Fatal error: Crash error: using $ this if not in the context of an object in C: \ XAMPP \ HTDOCS \ mysite.com \ content-sorts \ Plugins \ WooCommerce-subscriptions \ includes \ toilet-class-subscription.php: 1413
I create my own plugin and I select all subscriptions where post status = wc-activefrom the message table. I looked at the tables " woocommerce_order_items", " woocommerce_order_itemmeta" and " postmeta", but none of them provides a way to get related orders for a user subscription ...
If I only knew where the relationship is for users who buy subscriptions and related orders, then I can write some sql, but I have no idea, and google also does not give any results.
Any ideas?
My setup:
- php version 7.0.4
- Wordpress version 4.7.3
- woocommerce 2.6.8
- woocommerce subscription: 2.0.18
source
share