Automattic\WooCommerce\Admin\RemoteSpecs\RuleProcessors

OptionRuleProcessor::process()publicWC 1.0

Performs a comparison operation against the option value.

Метод класса: OptionRuleProcessor{}

Хуков нет.

Возвращает

true|false. The result of the operation.

Использование

$OptionRuleProcessor = new OptionRuleProcessor();
$OptionRuleProcessor->process( $rule, $stored_state );
$rule(объект) (обязательный)
The specific rule being processed by this rule processor.
$stored_state(объект) (обязательный)
Stored state.

Код OptionRuleProcessor::process() WC 8.9.0

public function process( $rule, $stored_state ) {
	$is_contains                     = $rule->operation && strpos( $rule->operation, 'contains' ) !== false;
	$value_when_default_not_provided = $is_contains ? array() : false;
	$is_default_set                  = property_exists( $rule, 'default' );
	$default_value                   = $is_default_set ? $rule->default : $value_when_default_not_provided;
	$option_value                    = $this->get_option_value( $rule, $default_value, $is_contains );

	if ( isset( $rule->transformers ) && is_array( $rule->transformers ) ) {
		$option_value = TransformerService::apply( $option_value, $rule->transformers, $is_default_set, $default_value );
	}

	return ComparisonOperation::compare(
		$option_value,
		$rule->value,
		$rule->operation
	);
}