Flsupport_Tokens::flsupport_possible_tokens( array $tokens = array(), array $args = array() )

The possible tokens.


Parameters Parameters

$tokens

(Optional)

Default value: array()

$args

(Optional)

Default value: array()


Top ↑

Return Return

(array)


Source Source

File: src/integrations/fluent-support/tokens/flsupport-tokens.php

	public function flsupport_possible_tokens( $tokens = array(), $args = array() ) {

		if ( ! automator_do_identify_tokens() ) {
			return $tokens;
		}

		$trigger_integration = (string) $args['integration'];

		if ( 'FLSUPPORT' === $trigger_integration ) {

			$add_action   = (string) $args['triggers_meta']['add_action'];
			$trigger_meta = (string) $args['meta'];

			$ticket_token_actions = apply_filters( 'uap_fl_support_ticket_tokens', array( 'fluent_support/ticket_created', 'fluent_support/response_added_by_customer', 'fluent_support/ticket_closed_by_customer' ), $args );

			$agent_token_actions = apply_filters( 'uap_fl_support_agent_tokens', array( 'fluent_support/response_added_by_customer', 'fluent_support/ticket_closed_by_customer' ), $args );

			$ticket_response_token_actions = apply_filters( 'uap_fl_support_ticket_response_tokens', array( 'fluent_support/response_added_by_customer' ), $args );

			if ( in_array( $add_action, $ticket_token_actions, true ) ) {

				$fields_tickets = array(
					array(
						'tokenId'         => 'FLSUPPORT-TICKET-ID',
						'tokenName'       => __( 'Ticket ID', 'uncanny-automator' ),
						'tokenType'       => 'text',
						'tokenIdentifier' => $trigger_meta,
					),
					array(
						'tokenId'         => 'FLSUPPORT-TICKET-TITLE',
						'tokenName'       => __( 'Ticket subject', 'uncanny-automator' ),
						'tokenType'       => 'text',
						'tokenIdentifier' => $trigger_meta,
					),
					array(
						'tokenId'         => 'FLSUPPORT-TICKET-CONTENT',
						'tokenName'       => __( 'Ticket details', 'uncanny-automator' ),
						'tokenType'       => 'text',
						'tokenIdentifier' => $trigger_meta,
					),
					array(
						'tokenId'         => 'FLSUPPORT-TICKET-PRIORITY',
						'tokenName'       => __( 'Ticket priority', 'uncanny-automator' ),
						'tokenType'       => 'text',
						'tokenIdentifier' => $trigger_meta,
					),
					array(
						'tokenId'         => 'FLSUPPORT-TICKET-PRODUCT_TITLE', /* $ticket->product->title */
						'tokenName'       => __( 'Ticket product', 'uncanny-automator' ),
						'tokenType'       => 'text',
						'tokenIdentifier' => $trigger_meta,
					),
				);

				if ( in_array( $add_action, $ticket_response_token_actions, true ) ) {

					$fields_tickets[] = array(
						'tokenId'         => 'FLSUPPORT-CONVERSATION-CONTENT',
						'tokenName'       => __( 'Ticket response', 'uncanny-automator' ),
						'tokenType'       => 'text',
						'tokenIdentifier' => $trigger_meta,
					);
				}

				// Following tokens are only applicable to specific triggers.
				if ( in_array( $add_action, $agent_token_actions, true ) ) {
					$fields_tickets[] = array(
						'tokenId'         => 'FLSUPPORT-AGENT-USERNAME', /* $agent->username */
						'tokenName'       => __( 'Ticket assignee username', 'uncanny-automator' ),
						'tokenType'       => 'text',
						'tokenIdentifier' => $trigger_meta,
					);

					$fields_tickets[] = array(
						'tokenId'         => 'FLSUPPORT-AGENT-EMAIL', /* $agent->email */
						'tokenName'       => __( 'Ticket assignee email', 'uncanny-automator' ),
						'tokenType'       => 'text',
						'tokenIdentifier' => $trigger_meta,
					);
				}

				$fields_tickets[] = array(
					'tokenId'         => 'FLSUPPORT-TICKET-ADMIN-URL',
					'tokenName'       => __( 'Ticket admin URL', 'uncanny-automator' ),
					'tokenType'       => 'text',
					'tokenIdentifier' => $trigger_meta,
				);

				$fields_customers = array(
					array(
						'tokenId'         => 'FLSUPPORT-CUSTOMER-EMAIL', /* $customer->email */
						'tokenName'       => __( 'Customer email', 'uncanny-automator' ),
						'tokenType'       => 'text',
						'tokenIdentifier' => $trigger_meta,
					),
					array(
						'tokenId'         => 'FLSUPPORT-CUSTOMER-FIRST-NAME',
						'tokenName'       => __( 'Customer first name', 'uncanny-automator' ),
						'tokenType'       => 'text',
						'tokenIdentifier' => $trigger_meta,
					),
					array(
						'tokenId'         => 'FLSUPPORT-CUSTOMER-LAST-NAME',
						'tokenName'       => __( 'Customer last name', 'uncanny-automator' ),
						'tokenType'       => 'text',
						'tokenIdentifier' => $trigger_meta,
					),
					array(
						'tokenId'         => 'FLSUPPORT-CUSTOMER-TITLE',
						'tokenName'       => __( 'Customer job title', 'uncanny-automator' ),
						'tokenType'       => 'text',
						'tokenIdentifier' => $trigger_meta,
					),
					array(
						'tokenId'         => 'FLSUPPORT-CUSTOMER-NOTE',
						'tokenName'       => __( 'Customer note', 'uncanny-automator' ),
						'tokenType'       => 'text',
						'tokenIdentifier' => $trigger_meta,
					),
					array(
						'tokenId'         => 'FLSUPPORT-CUSTOMER-STATUS',
						'tokenName'       => __( 'Customer status', 'uncanny-automator' ),
						'tokenType'       => 'text',
						'tokenIdentifier' => $trigger_meta,
					),
					array(
						'tokenId'         => 'FLSUPPORT-CUSTOMER-ADDRESS-LINE-1', /* $customer->address_line_1 */
						'tokenName'       => __( 'Customer address line 1', 'uncanny-automator' ),
						'tokenType'       => 'text',
						'tokenIdentifier' => $trigger_meta,
					),
					array(
						'tokenId'         => 'FLSUPPORT-CUSTOMER-CITY', /* $customer->city */
						'tokenName'       => __( 'Customer city', 'uncanny-automator' ),
						'tokenType'       => 'text',
						'tokenIdentifier' => $trigger_meta,
					),
					array(
						'tokenId'         => 'FLSUPPORT-CUSTOMER-STATE',
						'tokenName'       => __( 'Customer state', 'uncanny-automator' ),
						'tokenType'       => 'text',
						'tokenIdentifier' => $trigger_meta,
					),
					array(
						'tokenId'         => 'FLSUPPORT-CUSTOMER-ZIPCODE',
						'tokenName'       => __( 'Customer zip code', 'uncanny-automator' ),
						'tokenType'       => 'text',
						'tokenIdentifier' => $trigger_meta,
					),
					array(
						'tokenId'         => 'FLSUPPORT-CUSTOMER-COUNTRY',
						'tokenName'       => __( 'Customer country', 'uncanny-automator' ),
						'tokenType'       => 'text',
						'tokenIdentifier' => $trigger_meta,
					),
				);

				$tokens = array_merge( $tokens, $fields_tickets, $fields_customers );
				$tokens = Automator()->utilities->remove_duplicate_token_ids( $tokens );
			}
		}

		return $tokens;
	}