LLMS_Order::set_date( string $date_key, string $date_val )

Date field setter for date fields that require things to be updated when their value changes This is mainly used to allow updating dates which are editable from the admin panel which should trigger additional actions when updated


Description Description

Settable dates: date_next_payment, date_trial_end, date_access_expires


Parameters Parameters

$date_key

(string) (Required) date field to set

$date_val

(string) (Required) date string or a unix time stamp


Top ↑

Source Source

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

	public function set_date( $date_key, $date_val ) {

		// convert to timestamp if not already a timestamp
		if ( ! is_numeric( $date_val ) ) {
			$date_val = strtotime( $date_val );
		}

		$this->set( 'date_' . $date_key, date( 'Y-m-d H:i:s', $date_val ) );

		switch ( $date_key ) {

			// reschedule access expiration
			case 'access_expires':
				$this->maybe_schedule_expiration();
			break;

			// additionally update the next payment date
			// & don't break because we want to reschedule payments too
			case 'trial_end':
				$this->set_date( 'next_payment', $this->calculate_next_payment_date( 'U' ) );

				// everything else reschedule's payments
			default:
				$this->maybe_schedule_payment( false );

		}

	}

Top ↑

Changelog Changelog

Changelog
Version Description
3.10.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

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





Permalink: