uap_option_woocommerce_pro_statuses
Filters the WooCommerce Pro order statuses available for selection within the plugin.
add_filter( 'uap_option_woocommerce_pro_statuses', $callback, 10, 1 );
Description
This filter allows developers to modify the WooCommerce order statuses available for Uncanny Automator Pro triggers and actions. It fires when the available order statuses are being prepared for use within Automator's WooCommerce integration, providing an opportunity to add, remove, or alter the status options displayed to users.
Usage
add_filter( 'uap_option_woocommerce_pro_statuses', 'your_function_name', 10, 1 );
Parameters
-
$option(mixed) - This parameter holds the array of WooCommerce order statuses, which is filtered by the hook.
Return Value
The filtered value.
Examples
<?php
/**
* Example function to modify WooCommerce order statuses available in Uncanny Automator Pro.
*
* This function demonstrates how to use the 'uap_option_woocommerce_pro_statuses' filter
* to conditionally add or remove WooCommerce order statuses from the options presented
* within Uncanny Automator Pro's automation builder.
*
* For instance, you might want to exclude certain internal or cancelled statuses
* from being triggers or actions in your automations.
*
* @param array $option An array representing the options for the WooCommerce order statuses field.
* Expected keys include 'options' (an array of status slugs => status labels).
* @return array The modified $option array with potentially altered order statuses.
*/
function my_uncanny_automator_modify_woocommerce_statuses( $option ) {
// Ensure we are dealing with the expected structure of the $option array.
if ( ! isset( $option['options'] ) || ! is_array( $option['options'] ) ) {
return $option;
}
// Example: Remove 'on-hold' and 'failed' statuses from the available options.
$statuses_to_remove = array( 'wc-on-hold', 'wc-failed' );
foreach ( $statuses_to_remove as $status_slug ) {
if ( isset( $option['options'][ $status_slug ] ) ) {
unset( $option['options'][ $status_slug ] );
}
}
// You could also add custom statuses here if needed, though that's less common
// for this specific filter which is designed to work with existing wc_get_order_statuses().
return $option;
}
// Add the filter to WordPress.
// The second parameter '1' indicates that our callback function accepts only one argument.
add_filter( 'uap_option_woocommerce_pro_statuses', 'my_uncanny_automator_modify_woocommerce_statuses', 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
uncanny-automator-pro/src/integrations/woocommerce/helpers/woocommerce-pro-helpers.php:627
uncanny-automator-pro/src/integrations/woocommerce-subscription/fields/order-fields.php:388
public function wc_order_statuses_pro( $label = null, $option_code = 'WCORDERSTATUS' ) {
if ( ! $label ) {
$label = 'Status';
}
$option = array(
'option_code' => $option_code,
'label' => $label,
'input_type' => 'select',
'required' => true,
'options_show_id' => false,
'options' => wc_get_order_statuses(),
'default_value' => 'wc-completed',
);
return apply_filters( 'uap_option_woocommerce_pro_statuses', $option );
}