Filter
uncanny-automator-pro
automator_disable_wc_orderproductqty_trigger
Filters whether the WooCommerce order product quantity trigger should be disabled.
add_filter( 'automator_disable_wc_orderproductqty_trigger', $callback, 10, 1 );
Description
This filter allows developers to programmatically disable the "Product quantity in order" trigger for Uncanny Automator Pro's WooCommerce integration. Return `true` to disable the trigger entirely, preventing users from selecting or using it within their recipes. This can be useful for specific site configurations or to avoid potential conflicts.
Usage
add_filter( 'automator_disable_wc_orderproductqty_trigger', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
// Example of how to disable the "Product quantity in an order" trigger for Uncanny Automator Pro for WooCommerce.
// This could be useful if you have a specific scenario where this trigger might cause issues or is not needed.
add_filter(
'automator_disable_wc_orderproductqty_trigger',
function ( $disable_trigger ) {
// In this example, we'll disable the trigger if the current user is an administrator.
// You could replace this logic with any condition that makes sense for your site.
if ( current_user_can( 'manage_options' ) ) {
return true; // Disable the trigger
}
// If the condition is not met, return the original value (false) to keep the trigger enabled.
return $disable_trigger;
},
10, // Priority: 10 is the default, but you can adjust if needed.
1 // Accepted args: The filter receives one argument ($disable_trigger).
);
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/triggers/wc-orderproductqty.php:49
public function define_trigger() {
// Check if trigger should be disabled
if ( apply_filters( 'automator_disable_wc_orderproductqty_trigger', false ) ) {
return;
}
$trigger = array(
'author' => Automator()->get_author_name( $this->trigger_code ),
'support_link' => Automator()->get_author_support_link( $this->trigger_code, 'integration/woocommerce/' ),
'is_pro' => true,
'is_deprecated' => true, // Mark as deprecated
'deprecated_since' => '6.9.0', // Version when deprecated
'deprecated_message' => esc_html_x( 'This trigger is deprecated. Please use the new WooCommerce triggers instead.', 'Woocommerce', 'uncanny-automator-pro' ),
'integration' => self::$integration,
'code' => $this->trigger_code,
/* translators: Logged-in trigger - WooCommerce. 2. Currency symbol */
'sentence' => sprintf(
//translators: %1$s: Number condition, %2$s: Product, %3$s: Quantity, %4$s: Trigger condition
esc_html_x( 'A user {{completes, pays for, lands on a thank you page for:%4$s}} an order with a quantity {{greater than, less than or equal to:%1$s}} {{a quantity:%3$s}} of {{a product:%2$s}}', 'Woocommerce', 'uncanny-automator-pro' ),
'NUMBERCOND',
$this->trigger_product,
$this->trigger_meta,
$this->trigger_condition
),
/* translators: %1$s: Number condition, %2$s: Product, %3$s: Quantity, %4$s: Trigger condition */
'select_option_name' => esc_html_x( 'A user {{completes, pays for, lands on a thank you page for}} an order with a quantity {{greater than, less than or equal to}} {{a quantity}} of {{a product}}', 'Woocommerce', 'uncanny-automator-pro' ),
'action' => array(
'woocommerce_order_status_completed',
'woocommerce_thankyou',
'woocommerce_payment_complete',
),
'priority' => 99,
'accepted_args' => 1,
'validation_function' => array( $this, 'order_completed' ),
'options_callback' => array( $this, 'load_options' ),
);
$trigger = Woocommerce_Pro_Helpers::add_loopable_tokens( $trigger );
Automator()->register->trigger( $trigger );
}