wordpress woocomerce subscriptions and Membership error


I am adding the custom code in the function create_subscription ()

here is the code which gives the error ,,,I have mentioned in comments which line gives the error

$renewal = wcs_order_contains_renewal($parent_order->get_id());
        if ($renewal == false) {
            if ($trial_length > 0) {
                $dates = array(
                    'trial_end' => $next_payment,
                    'next_payment' => $next_payment,
                try {
                    $subscription->update_dates($dates); //this code line gives the error it works fine if I comment this line
                } catch (Exception $e) {
                    f24_write_data_to_file('Error in updating Trial end date ');


        $this->subscription = $subscription;

        // On order created.
        do_action('paywall/wc_subscription_created', $subscription);

        return $subscription;

and here is the error which I got ,,, I am using the woocommerce subscriptions plugin and Woocommerce Membership Plugin, Need help now, how to fix the error while updating the trial_end date?

enter image description here

, , Sher Muhammad 1 year 2020-07-17T06:11:20-05:00 0 Answers 60 views 0

Leave an answer