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.


Top ↑

Return Return

(int[]) Returns an array of WP_Post IDs for orders successfully rescheduled by the method.


Top ↑

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;

	}


Top ↑

Changelog 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.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.