0

I have over 30,000 users with expired WooCommerce Subscriptions that I am looking to easily extend. Is there a way that I can do this programmatically? Or a simple MySQL statement that I can run? Has anyone done this before? Any help will be greatly appreciated!

mujuonly
  • 11,370
  • 5
  • 45
  • 75
apalin
  • 13
  • 1

1 Answers1

0
add_action( 'admin_init', 'change_expired_subscription_to_active' );

function change_expired_subscription_to_active() {
    $expired_subscriptions = get_posts( array( 'post_type' => 'shop_subscription', 'post_status' => 'wc-expired' ) );
    if(!empty(expired_subscriptions)){
      foreach ( $expired_subscriptions as $post ) {
        update_post_meta( $post->ID, '_requires_manual_renewal', true );
        wp_update_post( array( 'ID' => $post->ID, 'post_status' => 'wc-active' ) );
    }
  }
}

Try this code

mujuonly
  • 11,370
  • 5
  • 45
  • 75