admin管理员组文章数量:1193366
I want to get the updated subscription expiration date when a user successfully completes renewal payment or his card gets charged when trial ends. Is there a way to get the updated date in woocommerce_subscription_renewal_payment_complete hook or in any other hook? I need to tell a third party service that subscription has been updated so that it should update its renewal date that code should supply. So for I have come with below code but I am not able get the updated subscription expiration date.
function cp_subscription_updated($subscription,$last_order ){
//print_R($last_order);
$last_order->update_status( 'completed' );
$sub_date = WC_Subscriptions_Order::get_next_payment_date ( $last_order, $subscription->get_id() );
update_user_meta($subscription->get_id(),'sub_date',$sub_date);
$userData= array('subscription_id' => $cp_sub_id ,'increase_date' =>date('m/d/Y',$sub_date));
reg_api_register($userData,API_ENDPOINT_UPDATE_SUBS);
return $last_order;
}
add_action('woocommerce_subscription_renewal_payment_complete','cp_subscription_updated',10,2);
I want to get the updated subscription expiration date when a user successfully completes renewal payment or his card gets charged when trial ends. Is there a way to get the updated date in woocommerce_subscription_renewal_payment_complete hook or in any other hook? I need to tell a third party service that subscription has been updated so that it should update its renewal date that code should supply. So for I have come with below code but I am not able get the updated subscription expiration date.
function cp_subscription_updated($subscription,$last_order ){
//print_R($last_order);
$last_order->update_status( 'completed' );
$sub_date = WC_Subscriptions_Order::get_next_payment_date ( $last_order, $subscription->get_id() );
update_user_meta($subscription->get_id(),'sub_date',$sub_date);
$userData= array('subscription_id' => $cp_sub_id ,'increase_date' =>date('m/d/Y',$sub_date));
reg_api_register($userData,API_ENDPOINT_UPDATE_SUBS);
return $last_order;
}
add_action('woocommerce_subscription_renewal_payment_complete','cp_subscription_updated',10,2);
Share
Improve this question
edited Feb 17, 2021 at 10:14
Rup
4,3904 gold badges28 silver badges29 bronze badges
asked Feb 17, 2021 at 5:52
deepsinghdeepsingh
112 bronze badges
1 Answer
Reset to default 2This one works for me:
add_action( 'woocommerce_subscription_renewal_payment_complete', 'subscription_renewal_payment_complete', 11, 2 );
function subscription_renewal_payment_complete( $subscription, $order ){
$subscription_id = $subscription->get_id();
$order_id = $order->get_id();
$billing_email = $subscription->get_billing_email();
$next_payment = $subscription->get_date('next_payment', 'site');
}
本文标签:
版权声明:本文标题:How to get woocommerce subscription next payment date or date when subscription expires in woocommerce_subscription_renewal_paym 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738473260a2088712.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论