Filter uncanny-automator-pro

automator_jet_crm_validate_common_quotes_possible_triggers_tokens

Filters the possible trigger tokens for Jet CRM quote events, allowing modification of available quote-related triggers.

add_filter( 'automator_jet_crm_validate_common_quotes_possible_triggers_tokens', $callback, 10, 1 );

Description

Filters possible tokens for Jet CRM quote triggers. Allows developers to add or remove specific trigger codes, controlling which Jet CRM quote events are available for automation. Modifying the default array of trigger codes like 'JETCRM_QUOTE_CREATED' is supported.


Usage

add_filter( 'automator_jet_crm_validate_common_quotes_possible_triggers_tokens', 'your_function_name', 10, 1 );

Parameters

$args (mixed)
This parameter contains an array of predefined quote-related trigger codes.

Return Value

The filtered value.


Examples

/**
 * Filters the possible trigger tokens for common JetCRM quote triggers.
 *
 * This function allows modifying the list of trigger codes that are considered
 * "common" quote triggers. For example, you might want to add a custom
 * trigger code that also relates to quotes.
 *
 * @param array $trigger_meta_validations An array of trigger codes that are considered common quote triggers.
 * @param array $args                     Additional arguments passed to the filter. Expected to contain 'triggers_meta' with a 'code' key.
 *
 * @return array The modified array of trigger codes.
 */
add_filter(
	'automator_jet_crm_validate_common_quotes_possible_triggers_tokens',
	function ( $trigger_meta_validations, $args ) {
		// Let's imagine we have a custom trigger code for a quote being "updated"
		// and we want to include it in the common quote triggers.
		$custom_quote_update_trigger_code = 'JETCRM_QUOTE_UPDATED';

		// Check if the custom trigger code is already in the list to avoid duplicates.
		if ( ! in_array( $custom_quote_update_trigger_code, $trigger_meta_validations, true ) ) {
			// Add our custom trigger code to the list.
			$trigger_meta_validations[] = $custom_quote_update_trigger_code;
		}

		// You could also potentially remove existing ones if needed, though less common for this hook's purpose.
		// For example, if you wanted to exclude 'JETCRM_QUOTE_ACCEPTED' for some reason:
		// $trigger_meta_validations = array_diff($trigger_meta_validations, array('JETCRM_QUOTE_ACCEPTED'));

		// Return the potentially modified array of trigger codes.
		return $trigger_meta_validations;
	},
	10, // Priority: Default priority is 10.
	2   // Accepted arguments: This filter accepts two arguments.
);

Placement

This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.


Source Code

uncanny-automator-pro/src/integrations/jet-crm/tokens/jetcrm-pro-tokens.php:216
uncanny-automator-pro/src/integrations/jet-crm/tokens/jetcrm-pro-tokens.php:284

public function jetcrm_quotes_possible_tokens( $tokens = array(), $args = array() ) {
		$trigger_code = $args['triggers_meta']['code'];

		$trigger_meta_validations = apply_filters(
			'automator_jet_crm_validate_common_quotes_possible_triggers_tokens',
			array( 'JETCRM_QUOTE_CREATED', 'JETCRM_QUOTE_ACCEPTED' ),
			$args
		);

		if ( in_array( $trigger_code, $trigger_meta_validations, true ) ) {

			$fields = array(
				array(
					'tokenId'         => 'object_id',
					'tokenName'       => __( 'Quote ID', 'uncanny-automator-pro' ),
					'tokenType'       => 'int',
					'tokenIdentifier' => $trigger_code,
				),
				array(
					'tokenId'         => 'zbsq_contact',
					'tokenName'       => __( 'Quote contact', 'uncanny-automator-pro' ),
					'tokenType'       => 'text',
					'tokenIdentifier' => $trigger_code,
				),
				array(
					'tokenId'         => 'zbsq_status',
					'tokenName'       => __( 'Quote status', 'uncanny-automator-pro' ),
					'tokenType'       => 'text',
					'tokenIdentifier' => $trigger_code,
				),
				array(
					'tokenId'         => 'zbsq_title',
					'tokenName'       => __( 'Quote title', 'uncanny-automator-pro' ),
					'tokenType'       => 'text',
					'tokenIdentifier' => $trigger_code,
				),
				array(
					'tokenId'         => 'zbsq_value',
					'tokenName'       => __( 'Quote value', 'uncanny-automator-pro' ),
					'tokenType'       => 'text',
					'tokenIdentifier' => $trigger_code,
				),
				array(
					'tokenId'         => 'zbsq_content',
					'tokenName'       => __( 'Quote content', 'uncanny-automator-pro' ),
					'tokenType'       => 'text',
					'tokenIdentifier' => $trigger_code,
				),
				array(
					'tokenId'         => 'zbsq_notes',
					'tokenName'       => __( 'Quote notes', 'uncanny-automator-pro' ),
					'tokenType'       => 'text',
					'tokenIdentifier' => $trigger_code,
				),
			);

			$tokens = array_merge( $tokens, $fields );
		}

		return $tokens;
	}

Scroll to Top