uap_wc_trigger_conditions
Filters WooCommerce Integrations' trigger conditions. Filters WooCommerce integration trigger conditions, allowing modification of action hook handles and labels.
add_filter( 'uap_wc_trigger_conditions', $callback, 10, 1 );
Description
Filters the available trigger conditions for Uncanny Automator's WooCommerce integrations. Developers can modify this array to add custom conditions or alter existing ones, mapping action hook handles to human-readable labels for display in the Automator interface.
Usage
add_filter( 'uap_wc_trigger_conditions', 'your_function_name', 10, 1 );
Parameters
-
$trigger_conditions(array) - An array of key-value pairs of action hook handle and human readable label.
Return Value
The filtered value.
Examples
/**
* Add a new trigger condition for when a WooCommerce order is refunded.
*
* @param array $trigger_conditions The existing array of trigger conditions.
* @return array The modified array of trigger conditions.
*/
add_filter( 'uap_wc_trigger_conditions', function( $trigger_conditions ) {
// Add a new condition for order refunds.
$trigger_conditions['woocommerce_order_refunded'] = __( 'refunds', 'your-text-domain' );
return $trigger_conditions;
}, 10, 1 );
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/woocommerce/helpers/woocommerce-helpers.php:287
uncanny-automator-pro/src/integrations/woocommerce/helpers/woocommerce-pro-helpers.php:1011
public function get_trigger_condition_labels() {
/**
* Filters WooCommerce Integrations' trigger conditions.
*
* @param array $trigger_conditions An array of key-value pairs of action hook handle and human readable label.
*/
return apply_filters(
'uap_wc_trigger_conditions',
array(
'woocommerce_payment_complete' => _x( 'pays for', 'WooCommerce', 'uncanny-automator' ),
'woocommerce_order_status_completed' => _x( 'completes', 'WooCommerce', 'uncanny-automator' ),
'woocommerce_thankyou' => _x( 'lands on a thank you page for', 'WooCommerce', 'uncanny-automator' ),
)
);
}