Created
February 16, 2021 17:05
-
-
Save growdev/ac33880961915c1b00d8cb28acf32268 to your computer and use it in GitHub Desktop.
Update next payment date for subscribers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Update next payment date for subscriptions. | |
* Run this script using WP CLI: | |
* $ wp eval-file update_next_payment.php | |
*/ | |
$subs = [ | |
// ids of subscriptions to update | |
]; | |
foreach ( $subs as $sub_id ) { | |
$new_billing = '2020-07-01 08:00:00'; | |
$sub = wcs_get_subscription( $sub_id ); | |
if ( $sub ) { | |
$sub->update_dates( [ 'next_payment' => $new_billing ] ); | |
echo "updated: " . $sub_id . PHP_EOL; | |
} else { | |
echo "ERROR sub_id not found: " . $sub_id . PHP_EOL; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks so much for posting this! Very much appreciated.