uap_option_woocommerce_statuses
Filters the available WooCommerce order statuses displayed in the Ultimate Affiliate Pro plugin settings.
add_filter( 'uap_option_woocommerce_statuses', $callback, 10, 1 );
Description
Fires when Uncanny Automator Pro prepares the WooCommerce order statuses for use in automations. Developers can filter the returned array to add, remove, or modify available order status options for triggers and actions. This hook is crucial for customizing how Uncanny Automator integrates with specific WooCommerce order workflows.
Usage
add_filter( 'uap_option_woocommerce_statuses', 'your_function_name', 10, 1 );
Parameters
-
$option(mixed) - This parameter contains the WooCommerce order statuses that will be used to populate a dropdown or select list for the Uncanny Automator Pro plugin.
Return Value
The filtered value.
Examples
add_filter( 'uap_option_woocommerce_statuses', 'my_custom_woocommerce_order_statuses', 10, 1 );
/**
* Filters the WooCommerce order statuses to add a custom status for specific automations.
*
* This example demonstrates how to add a custom order status to the list that Uncanny Automator
* can use for triggers or actions. It assumes you have a custom WooCommerce order status
* registered and it will be added to the default list.
*
* @param array $option The array of options for the WooCommerce order statuses.
* @return array The modified array of options.
*/
function my_custom_woocommerce_order_statuses( $option ) {
// Check if the 'options' key exists and is an array.
if ( ! isset( $option['options'] ) || ! is_array( $option['options'] ) ) {
return $option; // Return original if structure is unexpected.
}
// Define your custom order status slug and label.
// Ensure 'wc-processing-for-delivery' is a registered custom status in your WooCommerce setup.
$custom_status_slug = 'wc-processing-for-delivery';
$custom_status_label = __( 'Processing for Delivery', 'your-text-domain' );
// Add your custom status to the existing WooCommerce statuses.
// This merges your custom status with the default ones.
$option['options'][ $custom_status_slug ] = $custom_status_label;
// Optionally, you can sort the statuses alphabetically or in a custom order.
// asort( $option['options'] );
return $option;
}
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:254
uncanny-automator-pro/src/integrations/woocommerce/helpers/woocommerce-pro-helpers.php:1569
public function wc_order_statuses( $label = null, $option_code = 'WCORDERSTATUS' ) {
if ( ! $label ) {
$label = 'Status';
}
$option = array(
'option_code' => $option_code,
'label' => $label,
'input_type' => 'select',
'required' => true,
'options' => wc_get_order_statuses(),
);
return apply_filters( 'uap_option_woocommerce_statuses', $option );
}