我想在用户成功完成续费支付或试用期结束时向其卡收费时获取更新的订阅到期日期。有没有办法在woocommerce\\u subscription\\u renewal\\u payment\\u complete挂钩或任何其他挂钩中获取更新日期?我需要告诉第三方服务,订阅已更新,以便更新代码应提供的续订日期。因此,对于我来说,我提供了以下代码,但我无法获得更新的订阅到期日期。
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);
SO网友:Stanlay Forker
这一款适合我:
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\');
}