LLMS_Admin_Tool_Recurring_Payment_Rescheduler::query_orders()

Perform a DB query for orders to be handled by the tool


Return Return

(object[])


Top ↑

Source Source

File: includes/admin/tools/class-llms-admin-tool-recurring-payment-rescheduler.php

	protected function query_orders() {

		global $wpdb;

		$orders = $wpdb->get_results(
			"SELECT SQL_CALC_FOUND_ROWS p.ID
			   FROM {$wpdb->posts} AS p
		  LEFT JOIN {$wpdb->postmeta} AS m
			     ON p.ID = m.post_ID
			    AND m.meta_key = '_llms_plan_ended'
		  LEFT JOIN {$wpdb->prefix}actionscheduler_actions AS a
			     ON a.args   = CONCAT( '{\"order_id\":', p.ID, '}' )
			    AND a.hook   = 'llms_charge_recurring_payment'
			    AND a.status = 'pending'
			  WHERE 1
			    AND p.post_type   = 'llms_order'
			    AND p.post_status = 'llms-active'
			    AND a.action_id IS NULL
			    AND m.meta_value IS NULL
		   ORDER BY p.ID ASC
			  LIMIT 50
			;"
		); // no-cache ok -- Caching implemented in `get_orders()`.

		wp_cache_set( sprintf( '%s-total-results', $this->id ), $wpdb->get_var( 'SELECT FOUND_ROWS()' ), 'llms_tool_data' );

		return $orders;

	}


Top ↑

Changelog Changelog

Changelog
Version Description
4.7.0 Added SQL_CALC_FOUND_ROWS and improved query to exclude results with a completed payment plan.
4.6.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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