douxiuyu2028 2019-05-30 07:11
浏览 54

如何在用户订阅30天后自动重新激活用户订阅?

I have the following code below and I am trying to achieve the following objectives :

  • Change the wording hold to pause (this has been completed from the code below)
  • Once a user logs into their account and puts their subscription 'on-hold'. After 30 days I need their subscription to automatically move back to being 'Active' and for the monthly payments to continue.

I am using woocommerce subscriptions plugin.

What I have is below but it doesn't completely work, It has been a over a month for some users who have put their subscription on hold and they haven't automatically re-activated, so I'm hoping to fix this with Stack Overflows help :)

add_filter( 'wcs_view_subscription_actions', 'wpse_custom_action_after', 11, 2 );

function wpse_custom_action_after( $actions, $subscription ) {
    if (!empty($actions['suspend'])) {
        $date = strtotime('+1 months');
        $subscription_renew_date = date('Y-m-d', $date);
        $actions['suspend']['url'] = $actions['suspend']['url'].'&suspend_end_date='.$subscription_renew_date;
        $actions['suspend']['name'] = 'Pause';
    }
    return $actions;
}


add_action('woocommerce_customer_changed_subscription_to_on-hold','add_suspend_date_when_subscription_onhold');

function add_suspend_date_when_subscription_onhold($subscription) {
    // print_r();exit();
    $subscription_id = $subscription->get_id();
    $date = strtotime('+1 months');
    $subscription_renew_date = date('Y-m-d', $date);
    update_post_meta($subscription_id, 'suspend_date',$subscription_renew_date);
}

Any help is much appreciated.

Thanks

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 用vivado写数字逻辑实验报告撰写,FPGA实验
    • ¥15 为什么shp文件会有这种小方块?
    • ¥15 ecplise在连接数据库时显示加载驱动成功但是数据库连接失败
    • ¥15 visionmaster启动失败,提示为“机器不满足授权而被禁用”
    • ¥15 IDEA中圈复杂度如何具体设置
    • ¥50 labview采集不了数据
    • ¥15 Multisim红外倒车雷达仿真中距离问题
    • ¥15 请上面代码做什么处理或什么混淆
    • ¥15 英雄联盟自定义房间置顶
    • ¥15 W5500网线插上无反应