Filter uncanny-automator

automator_surecart_product_tokens

Filters SureCart product tokens, allowing modification of available tokens for use in automation workflows.

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

Description

Filters the available SureCart product tokens. Developers can use this hook to add, remove, or modify tokens that represent SureCart product details and can be used in Uncanny Automator. This is useful for extending the integration with custom product information.


Usage

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

Parameters

$tokens (mixed)
This filter hook allows you to modify the array of available SureCart product tokens that can be used in automations.

Return Value

The filtered value.


Examples

/**
 * Add a custom token to the SureCart product tokens list.
 *
 * This function hooks into the 'automator_surecart_product_tokens' filter
 * to add a new token that represents the product's SKU.
 *
 * @param array $tokens The original array of SureCart product tokens.
 * @return array The modified array of SureCart product tokens including the new SKU token.
 */
add_filter(
	'automator_surecart_product_tokens',
	function ( $tokens ) {
		// Check if the tokens array is in the expected format before adding.
		if ( ! is_array( $tokens ) ) {
			return $tokens; // Return original if not an array to prevent errors.
		}

		// Add a new token for the product SKU.
		$tokens['PRODUCT_SKU'] = array(
			'name' => esc_html__( 'Product SKU', 'your-text-domain' ),
		);

		return $tokens;
	},
	10, // Priority
	1  // 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

src/integrations/surecart/tokens/surecart-tokens.php:108
src/integrations/surecart/tokens/surecart-tokens.php:174

public function product_tokens() {

		$tokens = array(
			'PRODUCT_ID'             => array(
				'name' => esc_html_x( 'Product ID', 'Surecart', 'uncanny-automator' ),
			),
			'PRODUCT_THUMB'          => array(
				'name' => esc_html_x( 'Product image', 'Surecart', 'uncanny-automator' ),
			),
			'PRODUCT_THUMB_ID'       => array(
				'name' => esc_html_x( 'Product image ID', 'Surecart', 'uncanny-automator' ),
			),
			'PRODUCT_PRICE'          => array(
				'name' => esc_html_x( 'Product price', 'Surecart', 'uncanny-automator' ),
			),
			'PRODUCT_PRICE_ID'       => array(
				'name' => esc_html_x( 'Product price ID', 'Surecart', 'uncanny-automator' ),
			),
			'PRODUCT_PAYMENT_TYPE'   => array(
				'name' => esc_html_x( 'Product payment type', 'Surecart', 'uncanny-automator' ),
			),
			'PRODUCT_TRIAL_DAYS'     => array(
				'name' => esc_html_x( 'Product trial days', 'Surecart', 'uncanny-automator' ),
			),
			'PRODUCT_DOWNLOAD_URL'   => array(
				'name' => esc_html_x( 'Product download URL', 'Surecart', 'uncanny-automator' ),
			),
			'PRODUCT_DOWNLOAD_LINK'  => array(
				'name' => esc_html_x( 'Product download link', 'Surecart', 'uncanny-automator' ),
			),
			'PRODUCT_DOWNLOAD_TITLE' => array(
				'name' => esc_html_x( 'Product download title', 'Surecart', 'uncanny-automator' ),
			),
			'SUBSCRIPTION_ID'        => array(
				'name' => esc_html_x( 'Subscription ID', 'Surecart', 'uncanny-automator' ),
			),
			'ORDER_ID'               => array(
				'name' => esc_html_x( 'Order ID', 'Surecart', 'uncanny-automator' ),
			),
			'ORDER_DATE'             => array(
				'name' => esc_html_x( 'Order date', 'Surecart', 'uncanny-automator' ),
			),
			'ORDER_STATUS'           => array(
				'name' => esc_html_x( 'Order status', 'Surecart', 'uncanny-automator' ),
			),
			'ORDER_NUMBER'           => array(
				'name' => esc_html_x( 'Order number', 'Surecart', 'uncanny-automator' ),
			),
			'ORDER_PAID_AMOUNT'      => array(
				'name' => esc_html_x( 'Paid amount', 'Surecart', 'uncanny-automator' ),
			),
			'ORDER_SUBTOTAL'         => array(
				'name' => esc_html_x( 'Order subtotal', 'Surecart', 'uncanny-automator' ),
			),
			'ORDER_TOTAL'            => array(
				'name' => esc_html_x( 'Order total', 'Surecart', 'uncanny-automator' ),
			),
			'ORDER_DISCOUNT'         => array(
				'name' => esc_html_x( 'Order discount', 'Surecart', 'uncanny-automator' ),
			),
			'PAYMENT_METHOD'         => array(
				'name' => esc_html_x( 'Payment method', 'Surecart', 'uncanny-automator' ),
			),
			'ORDER_COUPON'           => array(
				'name' => esc_html_x( 'Coupon code', 'Surecart', 'uncanny-automator' ),
			),
		);

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

Scroll to Top