以编程方式扩展 WooCommerce 订阅
Programmatically extending a WooCommerce Subscription
我有超过 30,000 名用户的 WooCommerce 订阅已过期,我希望轻松延长这些订阅。有没有办法以编程方式执行此操作?或者我可以 运行 的简单 MySQL 语句?有没有人这样做过?任何帮助将不胜感激!
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' ) );
}
}
}
试试这个代码
我有超过 30,000 名用户的 WooCommerce 订阅已过期,我希望轻松延长这些订阅。有没有办法以编程方式执行此操作?或者我可以 运行 的简单 MySQL 语句?有没有人这样做过?任何帮助将不胜感激!
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' ) );
}
}
}
试试这个代码