LLMS_Access_Plan::is_on_sale()

Determine if a plan is *currently* on sale


Return Return

(boolean)


Top ↑

Source Source

File: includes/models/model.llms.access.plan.php

		$ret = false;

		if ( llms_parse_bool( $this->get( 'on_sale' ) ) ) {

			$now = llms_current_time( 'timestamp' );

			$start = $this->get( 'sale_start' );
			$end   = $this->get( 'sale_end' );

			// Add times if the values exist (start of day & end of day).
			$start = ( $start ) ? strtotime( $start . ' 00:00:00' ) : $start;
			$end   = ( $end ) ? strtotime( '+1 day', strtotime( $end . ' 00:00:00' ) ) : $end;

			// No dates, the product is indefinitely on sale.
			if ( ! $start && ! $end ) {

				$ret = true;

				// Start and end.
			} elseif ( $start && $end ) {

				$ret = ( $now < $end && $now > $start );

				// Only start.
			} elseif ( $start && ! $end ) {

				$ret = ( $now > $start );

				// Only end.
			} elseif ( ! $start && $end ) {

				$ret = ( $now < $end );

			}
		}

		return apply_filters( 'llms_plan_is_on_sale', $ret, $this );

	}



Top ↑

Changelog Changelog

Changelog
Version Description
3.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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