LLMS_Product::get_access_plans( boolean $free_only = false, boolean $visible_only = true )

Get all access plans for the product


Description Description


Parameters Parameters

$free_only

(boolean) (Optional) only include free access plans if true

Default value: false

$visible_only

(boolean) (Optional) excludes hidden access plans from results

Default value: true


Top ↑

Return Return

(array)


Top ↑

Source Source

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

	public function get_access_plans( $free_only = false, $visible_only = true ) {

		$args = array(
			'meta_key' => '_llms_product_id',
			'meta_value' => $this->get( 'id' ),
			'order' => 'ASC',
			'orderby' => 'menu_order',
			'posts_per_page' => $this->get_access_plan_limit(),
			'post_type' => 'llms_access_plan',
			'status' => 'publish',
		);

		// filter results to only free access plans
		if ( $free_only ) {
			$args['meta_query'] = array(
				array(
					'key' => '_llms_is_free',
					'value' => 'yes',
				),
			);
		}

		// exclude hidden access plans from the results
		if ( $visible_only ) {
			$args['tax_query'] = array(
				array(
					'field' => 'name',
					'operator' => 'NOT IN',
					'terms' => array( 'hidden' ),
					'taxonomy' => 'llms_access_plan_visibility',
				),
			);
		}

		$query = new WP_Query( apply_filters( 'llms_get_product_access_plans_args', $args, $this, $free_only, $visible_only ) );

		// retup return
		$plans = array();

		// if we have plans, setup access plan instances
		if ( $query->have_posts() ) {
			foreach ( $query->posts as $post ) {
				$plans[] = new LLMS_Access_Plan( $post );
			}
		}

		return apply_filters( 'llms_get_product_access_plans', $plans, $this, $free_only, $visible_only );

	}

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.