LLMS_Admin_Tool_Recurring_Payment_Rescheduler::handle()
Schedules payments and expiration for an order
Description Description
Retrieves orders from the get_orders() method and schedules a recurring payment and expiration action based on its existing calculated order data.
Return Return
(int[]) Returns an array of WP_Post IDs for orders successfully rescheduled by the method.
Source Source
File: includes/admin/tools/class-llms-admin-tool-recurring-payment-rescheduler.php
protected function handle() {
$orders = array();
foreach ( $this->get_orders() as $id ) {
$order = llms_get_post( $id );
$next = $order->get_next_payment_due_date();
if ( is_wp_error( $next ) && 'plan-ended' === $next->get_error_code() ) {
$order->set( 'plan_ended', 'yes' );
continue;
}
$order->maybe_schedule_payment( false );
$order->maybe_schedule_expiration();
if ( $order->get_next_scheduled_action_time( 'llms_charge_recurring_payment' ) ) {
$orders[] = $id;
}
}
wp_cache_delete( $this->id, 'llms_tool_data' );
wp_cache_delete( sprintf( '%s-total-results', $this->id ), 'llms_tool_data' );
return $orders;
}
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 4.7.0 | Set plan_ended metadata for orders with an ended plan and don't attempt to process them. |
| 4.6.0 | Introduced. |