LLMS_Admin_AddOns::get_product_from_cat( string $cat, array $excludes )

Get a random product from a category that doesn’t exist in the list of excluded product ids.


Parameters Parameters

$cat

(string) (Required) Category slug.

$excludes

(array) (Required) List of product ids to exclude.


Top ↑

Return Return

(array|false)


Top ↑

Source Source

File: includes/admin/class.llms.admin.addons.php

	public function get_product_from_cat( $cat, $excludes ) {

		$addons = $this->get_products_for_cat( $cat, true );
		shuffle( $addons );

		foreach ( $addons as $addon ) {

			if ( in_array( 'third-party', array_keys( $addon['categories'] ), true ) ) {
				continue;
			}

			if ( ! in_array( $addon['id'], $excludes, true ) ) {
				return $addon;
			}
		}

		return false;
	}


Top ↑

Changelog Changelog

Changelog
Version Description
7.1.0 Use strict comparisons for in_array().
3.22.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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