HEX
Server: Apache/2.4.65 (Ubuntu)
System: Linux ielts-store-v2 6.8.0-1036-gcp #38~22.04.1-Ubuntu SMP Thu Aug 14 01:19:18 UTC 2025 x86_64
User: root (0)
PHP: 7.2.34-54+ubuntu20.04.1+deb.sury.org+1
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,
Upload Files
File: /var/www/html/ielts-store/wp-content/plugins/automatewoo/includes/Rules/Order_Meta.php
<?php

namespace AutomateWoo\Rules;

use AutomateWoo\RuleQuickFilters\Clauses\ClauseInterface;
use AutomateWoo\Rules\Interfaces\QuickFilterable;
use AutomateWoo\Rules\Utilities\NumericQuickFilter;
use AutomateWoo\Rules\Utilities\StringQuickFilter;
use InvalidArgumentException;

defined( 'ABSPATH' ) || exit;

/**
 * @class Order_Meta
 */
class Order_Meta extends Abstract_Meta implements QuickFilterable {

	use StringQuickFilter, NumericQuickFilter;

	/** @var string */
	public $data_item = 'order';

	/** @var string the prefix of the property name for Quick Filter clauses */
	public static $property_prefix = 'meta.';

	/**
	 * Init the rule
	 */
	public function init() {
		$this->title = __( 'Order - Custom Field', 'automatewoo' );
	}


	/**
	 * Validate the rule based on options set by a workflow
	 * The $order passed will already be validated
	 *
	 * @param \WC_Order $order
	 * @param string    $compare_type
	 * @param array     $value_data
	 * @return bool
	 */
	public function validate( $order, $compare_type, $value_data ) {

		$value_data = $this->prepare_value_data( $value_data );

		if ( ! is_array( $value_data ) ) {
			return false;
		}

		return $this->validate_meta( $order->get_meta( $value_data['key'] ), $compare_type, $value_data['value'] );
	}

	/**
	 * Get quick filter clause for the rule.
	 *
	 * @since 5.1.0
	 *
	 * @param string $compare_type textual representation of the comparison operator
	 * @param array  $value array containing the custom meta key and value
	 *
	 * @return ClauseInterface StringClause, NumericClause, or NoOpClause
	 *
	 * @throws InvalidArgumentException When there's an error generating the clause.
	 */
	public function get_quick_filter_clause( $compare_type, $value ) {

		$value_data = $this->prepare_value_data( $value );
		if ( ! is_array( $value_data ) ) {
			throw new InvalidArgumentException();
		}

		// Use NumericClause for numeric comparisons (greater/less/multiples) and for is/is not ONLY with numeric values
		if ( $this->is_numeric_meta_field( $compare_type, $value_data['value'] ) ) {
			$meta_clause = $this->generate_numeric_quick_filter_clause( self::$property_prefix . $value_data['key'], $compare_type, $value_data['value'] );
		} else {
			$meta_clause = $this->generate_string_quick_filter_clause( self::$property_prefix . $value_data['key'], $compare_type, $value_data['value'] );
		}

		return $meta_clause;
	}

}