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

Retrieve the due date of the next payment according to access plan terms


Parameters Parameters

$format

(string) (Optional) Date return format. Default is 'Y-m-d H:i:s'.

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


Top ↑

Return Return

(string)


Top ↑

Source Source

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

	 * @return string
	 */
	public function get_next_payment_due_date( $format = 'Y-m-d H:i:s' ) {

		// Single payments will never have a next payment date.
		if ( ! $this->is_recurring() ) {
			return new WP_Error( 'not-recurring', __( 'Order is not recurring', 'lifterlms' ) );
		} elseif ( ! in_array( $this->get( 'status' ), array( 'llms-active', 'llms-failed', 'llms-on-hold', 'llms-pending', 'llms-pending-cancel' ), true ) ) {
			return new WP_Error( 'invalid-status', __( 'Invalid order status', 'lifterlms' ), $this->get( 'status' ) );
		}

		// Retrieve the saved due date.
		$next_payment_time = $this->get_date( 'date_next_payment', 'U' );
		// Calculate it if not saved.
		if ( ! $next_payment_time ) {
			$next_payment_time = $this->calculate_next_payment_date( 'U' );
			if ( ! $next_payment_time ) {
				return new WP_Error( 'plan-ended', __( 'No more payments due', 'lifterlms' ) );
			}
		}

		/**
		 * Filter the next payment due date.
		 *
		 * A timestamp should always be returned as the conversion to the requested format
		 * will be performed on the returned value.
		 *
		 * @since 3.0.0
		 *
		 * @param int        $next_payment_time Unix timestamp for the next payment due date.
		 * @param LLMS_Order $order             Order object.
		 * @param string     $format            Requested date format.
		 */
		$next_payment_time = apply_filters( 'llms_order_get_next_payment_due_date', $next_payment_time, $this, $format );

		return date_i18n( $format, $next_payment_time );


Top ↑

Changelog Changelog

Changelog
Version Description
5.2.0 Use stric type comparisons.
3.19.0 Unknown.
3.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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