LLMS_Order::get_start_date( string $format = 'Y-m-d H:i:s' )

Get the start date for the order.


Description Description

Gets the date of the first initially successful transaction if none found, uses the created date of the order.


Top ↑

Parameters Parameters

$format

(string) (Optional) Desired return format of the date.

Default value: 'Y-m-d H:i:s'


Top ↑

Return Return

(string)


Top ↑

Source Source

File: includes/models/model.llms.order.php

	public function get_start_date( $format = 'Y-m-d H:i:s' ) {
		/**
		 * Get the first recorded transaction.
		 * Refunds are okay b/c that would have initially given the user access.
		 */
		$txns = $this->get_transactions(
			array(
				'order'         => 'ASC',
				'orderby'       => 'date',
				'per_page'      => 1,
				'status'        => array( 'llms-txn-succeeded', 'llms-txn-refunded' ),
				'type'          => 'any',
				'no_found_rows' => true,
			)
		);
		if ( $txns['count'] ) {
			$txn  = array_pop( $txns['transactions'] );
			$date = $txn->get_date( 'date', $format );
		} else {
			$date = $this->get_date( 'date', $format );
		}

		/**
		 * Filter the order start date.
		 *
		 * @since 3.0.0
		 * @since 7.1.0 Added the `$format` parameter.
		 *
		 * @param string     $date   The formatted start date for the order.
		 * @param LLMS_Order $order  The order object.
		 * @param string     $format The requested format of the date.
		 */
		return apply_filters( 'llms_order_get_start_date', $date, $this, $format );
	}


Top ↑

Changelog Changelog

Changelog
Version Description
7.1.0 Skip counting the total rows found when retrieving the first transaction.
3.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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