phpwordpresswoocommercesubscriptionwoothemes

WC_Subscription::update_dates( $dates, $timezone ) is no longer valid?


Seems as though the function WC_Subscription::update_dates( $dates, $timezone ) is no longer valid in the 3.0+ update, because the of the CRUD platform?

How do I go about finding the right function to use, as this is what's on the website. I basically have a loop that gets all active subscriptions and I want to update the next_payment_date. Now, if you do this just through the database, it won't update, so you have to run it through this function so it updates all the schedulers etc.

If I run, something similar to this, I get a 500 error. Any help would be greatly appreciated.

<?php 
WC_Subscription::update_dates( array(
      'next_payment' => '2017-05-30 04:30:00'
) );
?>

Solution

  • I believe I figured it out, instead of calling it directly, I instantiated it first.

    My bad. IE: I was trying to call it directly instead of instantiating it first.

    WC_Subscription::update_dates( $dates, $timezone );
    
    # SET subscription 
    $sub = new WC_Subscription($subscription->ID); 
    # UPDATE dates 
    $sub->update_dates(array('next_payment' => $new_payment_date));