You can get the parent order ID from the renewal ID by first getting the subscriptions that are associated with the renewal order (it returns as an array but there will be only 1 as each renewal order is specific to a subscription), and then by getting the (parent) order ID from the subscription.
$parentOrderID = '';
$orderID = $orderObj->get_id();
$subscriptions = wcs_get_subscriptions_for_order($orderID, ['order_type' => 'any']);
foreach ($subscriptions as $subscriptionID => $subscriptionObj) {
$parentOrderID = $subscriptionObj->order->get_id();
}
echo $parentOrderID;
'; i will get a WP error ... ? didn't i have to define $subscription first? BR Alex – GrünerAugust Oct 07 '20 at 09:05