Is it possible to get the Subscription id from the Woocommerce order id with the API of WooCommerce?
I’m using PHP and with this I can get all the order data, but not subscription id:
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => "https://www.example.com/wp-json/wc/v3/orders/".$orderId,
CURLOPT_USERPWD => 'code:code',
CURLOPT_HTTPHEADER => array(
"accept: application/json"
)
]);
$woocommerceOrder = curl_exec($curl);
2
Answers
I've solved with this code in my functions.php file in Wordpress:
Thanks to mujuonly for the reference and for the initial snippet.
Add this code snippet in your server active theme function.php. Then the order API response will contain the subscription_id