Ec_Tokens::parse_ec_tokens( $value,  $pieces,  $recipe_id,  $trigger_data,  $user_id,  $replace_args )

Parse the token.


Parameters Parameters

$value

(Required)

$pieces

(Required)

$recipe_id

(Required)

$trigger_data

(Required)

$user_id

(Required)

$replace_args

(Required)


Top ↑

Return Return

(null|string)


Source Source

File: src/integrations/event-tickets/tokens/ec-tokens.php

	public function parse_ec_tokens( $value, $pieces, $recipe_id, $trigger_data, $user_id, $replace_args ) {

		$piece = 'ECEVENTS';
		if ( $pieces ) {
			if ( in_array( $piece, $pieces ) ) {
				if ( $trigger_data ) {
					global $wpdb;
					foreach ( $trigger_data as $trigger ) {
						if ( key_exists( $piece, $trigger['meta'] ) ) {
							$token_info     = explode( '|', $pieces[2] );
							$meta_key       = isset( $token_info[1] ) ? $token_info[1] : '';
							$order_id       = $wpdb->get_var( $wpdb->prepare( "SELECT meta_value FROM {$wpdb->prefix}uap_trigger_log_meta WHERE meta_key = 'ec_order_id' AND automator_trigger_id = %d AND automator_trigger_log_id = %d ORDER BY ID DESC LIMIT 0,1", $trigger['ID'], $replace_args['trigger_log_id'] ) );
							$attendees_data = get_post_meta( $order_id, '_tribe_tickets_meta', true );
							$attendees_data = maybe_unserialize( $attendees_data );
							if ( ! empty( $attendees_data ) ) {
								if ( is_array( $attendees_data ) && ! empty( $meta_key ) ) {
									foreach ( $attendees_data as $attendees ) {
										foreach ( $attendees as $attendee ) {
											$value = isset( $attendee[ $meta_key ] ) ? $attendee[ $meta_key ] : '';
											if ( is_array( $value ) ) {
												$value = implode( ', ', $value );
											}
										}
									}
								}
							}
						}
					}//end foreach
				}//end if
			}//end if
		}//end if

		return $value;
	}