llms_update_3120_update_order_end_dates()

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


Description Description


Source Source

File: includes/functions/llms.functions.updates.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;"
	);

	foreach ( $ids as $id ) {

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

		$order->maybe_schedule_payment( true );

	}

}


Top ↑

User Contributed Notes User Contributed Notes

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





Permalink: