Skip to content

Instantly share code, notes, and snippets.

@growdev
Created February 16, 2021 17:05
Show Gist options
  • Select an option

  • Save growdev/ac33880961915c1b00d8cb28acf32268 to your computer and use it in GitHub Desktop.

Select an option

Save growdev/ac33880961915c1b00d8cb28acf32268 to your computer and use it in GitHub Desktop.
Update next payment date for subscribers
<?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;
}
}
@growdev

growdev commented May 12, 2021

Copy link
Copy Markdown
Author

You're welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment