Filter uncanny-automator-pro

automator_surecart_subscription_tokens

Filters SureCart subscription tokens before they are processed, allowing customization of available replacement data.

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

Description

Filters SureCart subscription tokens available in Uncanny Automator. Developers can add or modify tokens for SureCart subscriptions. This hook fires after SureCart tokens are initially generated, allowing customization before they are presented to the user for use in recipes.


Usage

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

Parameters

$tokens (mixed)
This parameter is an array of tokens representing SureCart subscription details, such as the subscription ID and price name, that can be used within Uncanny Automator workflows.

Return Value

The filtered value.


Examples

<?php
/**
 * Add a custom token for the subscription renewal date to the SureCart subscription tokens.
 *
 * This function hooks into the 'automator_surecart_subscription_tokens' filter to add
 * a new token that represents the date when a subscription is due for renewal.
 *
 * @param array $tokens The existing SureCart subscription tokens.
 * @return array The modified tokens array, including the new renewal date token.
 */
add_filter(
	'automator_surecart_subscription_tokens',
	function ( $tokens ) {
		// Add a new token for the subscription renewal date.
		$tokens[] = array(
			'tokenId'   => 'SUBSCRIPTION_RENEWAL_DATE',
			'tokenName' => esc_html_x( 'Subscription renewal date', 'Surecart', 'uncanny-automator' ),
			'tokenType' => 'text', // Assuming the renewal date will be formatted as text
		);

		return $tokens;
	},
	10, // Priority
	1  // Number of accepted 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/surecart/tokens/surecart-pro-tokens-new-framework.php:73

public function subscription_tokens() {

			$tokens = array(
				array(
					'tokenId'   => 'SUBSCRIPTION_ID',
					'tokenName' => esc_html_x( 'Subscription ID', 'Surecart', 'uncanny-automator' ),
					'tokenType' => 'text',
				),
				array(
					'tokenId'   => 'SUBSCRIPTION_PRICE_NAME',
					'tokenName' => esc_html_x( 'Subscription name', 'Surecart', 'uncanny-automator' ),
					'tokenType' => 'text',
				),
				array(
					'tokenId'   => 'SUBSCRIPTION_PRICE_ID',
					'tokenName' => esc_html_x( 'Subscription price ID', 'Surecart', 'uncanny-automator' ),
					'tokenType' => 'text',
				),
				array(
					'tokenId'   => 'SUBSCRIPTION_PRICE_AMOUNT',
					'tokenName' => esc_html_x( 'Subscription amount', 'Surecart', 'uncanny-automator' ),
					'tokenType' => 'text',
				),
				array(
					'tokenId'   => 'SUBSCRIPTION_PRICE_CURRENCY',
					'tokenName' => esc_html_x( 'Subscription price currency', 'Surecart', 'uncanny-automator' ),
					'tokenType' => 'text',
				),
				array(
					'tokenId'   => 'SUBSCRIPTION_PRICE_PERIOD',
					'tokenName' => esc_html_x( 'Subscription period', 'Surecart', 'uncanny-automator' ),
					'tokenType' => 'text',
				),
				array(
					'tokenId'   => 'SUBSCRIPTION_TAX',
					'tokenName' => esc_html_x( 'Subscription price tax included', 'Surecart', 'uncanny-automator' ),
					'tokenType' => 'text',
				),
				array(
					'tokenId'   => 'SUBSCRIPTION_PAYMENT_METHOD',
					'tokenName' => esc_html_x( 'Subscription payment method', 'Surecart', 'uncanny-automator' ),
					'tokenType' => 'text',
				),
				array(
					'tokenId'   => 'SUBSCRIPTION_PRODUCT_NAME',
					'tokenName' => esc_html_x( 'Subscription product name', 'Surecart', 'uncanny-automator' ),
					'tokenType' => 'text',
				),
				array(
					'tokenId'   => 'SUBSCRIPTION_PRODUCT_IMAGE_URL',
					'tokenName' => esc_html_x( 'Subscription product image URL', 'Surecart', 'uncanny-automator' ),
					'tokenType' => 'text',
				),
			);

			return apply_filters( 'automator_surecart_subscription_tokens', $tokens );
		}

Scroll to Top