Filter
uncanny-automator-pro
automator_woocommerce_coupon_tokens
Filters the available tokens for WooCommerce coupons within the Automator integration.
add_filter( 'automator_woocommerce_coupon_tokens', $callback, 10, 1 );
Description
Filters the available tokens for Uncanny Automator's WooCommerce "Create and Email Coupon" action. Developers can add custom coupon tokens here to be used in automation recipes. This hook fires when populating the token dropdown.
Usage
add_filter( 'automator_woocommerce_coupon_tokens', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
// Add a new token to represent the coupon's description.
add_filter( 'automator_woocommerce_coupon_tokens', 'my_custom_coupon_tokens', 10, 1 );
/**
* Adds a custom token for the WooCommerce coupon description to Uncanny Automator.
*
* @param array $tokens The existing available tokens.
* @return array The modified array of tokens including the new description token.
*/
function my_custom_coupon_tokens( $tokens ) {
// Add a new token to represent the coupon's description.
$tokens[] = '{{coupon_description}}';
return $tokens;
}
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/woocommerce/actions/wc-createandemailcoupon.php:87
}
/**
* @return array
*/
public function load_options() {
$available_codes = apply_filters(
'automator_woocommerce_coupon_tokens',
array(
'{{coupon_code}}',
'{{coupon_amount}}',
'{{coupon_expiry_date}}',
'{{coupon_minimum_spend}}',
)