WC_Product_Usage_Rule_Set{}WC 1.0

WC_Product_Usage_Rule_Set.

No Hooks.

Usage

$WC_Product_Usage_Rule_Set = new WC_Product_Usage_Rule_Set();
// use class methods

Methods

  1. public __construct( $rules )
  2. public get_rule( string $rule_name )

WC_Product_Usage_Rule_Set{} code WC 9.4.2

class WC_Product_Usage_Rule_Set {
	/**
	 * Set of product feature restriction rules.
	 *
	 * @var array|null $rules
	 */
	protected $rules;

	/**
	 * Constructor
	 *
	 * @param array $rules product feature restriction rules.
	 */
	public function __construct( $rules ) {
		$this->rules = $rules;
	}

	/**
	 * Retrieve the value of a rule by name
	 *
	 * @param string $rule_name name of the rule to retrieve value.
	 * @return mixed|null
	 */
	public function get_rule( string $rule_name ) {
		if ( ! isset( $this->rules[ $rule_name ] ) ) {
			return null;
		}

		return $this->rules[ $rule_name ];
	}
}