llms_update_3120_update_order_end_dates()

Add end dates to LifterLMS Orders which have a length but no saved end date


Return Return

(void)


Top ↑

Source Source

File: includes/functions/updates/llms-functions-updates-3120.php

function llms_update_3120_update_order_end_dates() {

	global $wpdb;

	$ids = $wpdb->get_col(
		"SELECT posts.ID
		 FROM {$wpdb->posts} AS posts
		 JOIN {$wpdb->postmeta} AS meta1 ON meta1.post_id = posts.ID AND meta1.meta_key = '_llms_billing_length'
		 LEFT JOIN {$wpdb->postmeta} AS meta2 ON meta2.post_id = posts.ID AND meta2.meta_key = '_llms_date_billing_end'
		 WHERE posts.post_type = 'llms_order'
		   AND meta2.meta_value IS NULL
		   AND meta1.meta_value > 0;"
	); // db call ok; no-cache ok.

	foreach ( $ids as $id ) {

		$order = llms_get_post( $id );
		if ( ! is_a( $order, 'LLMS_Order' ) ) {
			continue;
		}

		$order->maybe_schedule_payment( true );

	}

}


Top ↑

Changelog Changelog

Changelog
Version Description
3.12.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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