Advanced_Coupons_Tokens::acfwc_parse_tokens( $value,  $pieces,  $recipe_id,  $trigger_data,  $user_id,  $replace_args )


Parameters Parameters

$value

(Required)

$pieces

(Required)

$recipe_id

(Required)

$trigger_data

(Required)

$user_id

(Required)

$replace_args

(Required)


Top ↑

Return Return

(mixed|string)


Source Source

File: src/integrations/advanced-coupons/tokens/advanced-coupons-tokens.php

	public function acfwc_parse_tokens( $value, $pieces, $recipe_id, $trigger_data, $user_id, $replace_args ) {
		if ( ! $pieces ) {
			return $value;
		}
		$to_match = array(
			'ACFWCUSERRECEIVESCREDIT',
			'ACFWCUSERSPENDSCREDIT',
			'ACFWCSPENDSCREDIT',
			'ACFWCRECEIVESCREDIT',
		);

		if ( array_intersect( $to_match, $pieces ) ) {
			/** @var Wc_Tokens $wc_tokens */
			$wc_tokens = Utilities::get_class_instance( 'Uncanny_Automator\WC_TOKENS' );
			if ( method_exists( $wc_tokens, 'replace_values' ) ) {
				$value = $wc_tokens->replace_values( $value, $pieces, $recipe_id, $trigger_data, $user_id, $replace_args );
			}
		}

		if ( in_array( 'ACFWC_AMOUNT', $pieces, true ) ) {
			return $this->get_token_value( $pieces );
		}

		if ( in_array( 'ACFWC_SPEND_AMOUNT', $pieces, true ) ) {
			return $this->get_token_value( $pieces );
		}

		if ( in_array( 'USERTOTALCREDIT', $pieces, true ) ) {
			return $this->get_token_value( $pieces );
		}

		if ( in_array( 'USERLIFETIMECREDIT', $pieces, true ) ) {
			return $this->get_token_value( $pieces );
		}

		return $value;
	}