uap_option_all_wc_payment_gateways
Filters available WooCommerce payment gateways for United Affiliates Pro when displaying options.
add_filter( 'uap_option_all_wc_payment_gateways', $callback, 10, 1 );
Description
This filter allows developers to modify the list of available WooCommerce payment gateways displayed in Uncanny Automator Pro. Use it to exclude specific gateways, add custom ones, or alter their display within Automator recipes. The `$option` parameter contains the current array of payment gateway options.
Usage
add_filter( 'uap_option_all_wc_payment_gateways', 'your_function_name', 10, 1 );
Parameters
-
$option(mixed) - This parameter is used to modify or retrieve the value of the payment gateway option, potentially influencing the list of available WooCommerce payment gateways.
Return Value
The filtered value.
Examples
add_filter( 'uap_option_all_wc_payment_gateways', 'my_custom_wc_payment_gateways_filter', 10, 1 );
/**
* Filters the WooCommerce payment gateways available for Uncanny Automator Pro.
* This example disables the 'cod' (Cash on Delivery) payment gateway.
*
* @param array $option The original array of payment gateway options.
* @return array The modified array of payment gateway options.
*/
function my_custom_wc_payment_gateways_filter( $option ) {
// Check if the 'options' key exists and is an array before proceeding.
if ( isset( $option['options'] ) && is_array( $option['options'] ) ) {
// Check if the 'cod' payment gateway exists in the options.
if ( isset( $option['options']['cod'] ) ) {
// Remove the 'cod' payment gateway from the options.
unset( $option['options']['cod'] );
}
}
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
uncanny-automator-pro/src/integrations/woocommerce/helpers/woocommerce-pro-helpers.php:676
uncanny-automator-pro/src/integrations/woocommerce-subscription/fields/order-fields.php:918
public function all_wc_payment_gateways( $label = null, $option_code = 'WOOPAYMENTGATEWAY', $args = array(), $is_any = true ) {
$description = key_exists( 'description', $args ) ? $args['description'] : false;
$required = key_exists( 'required', $args ) ? $args['required'] : true;
if ( ! $label ) {
$label = esc_html_x( 'Payment method', 'WooCommerce', 'uncanny-automator-pro' );
}
$methods = WC()->payment_gateways->payment_gateways();
$options = array();
if ( true === $is_any ) {
$options['-1'] = esc_html_x( 'Any payment method', 'WooCommerce', 'uncanny-automator-pro' );
}
foreach ( $methods as $method ) {
if ( 'yes' === $method->enabled ) {
$title = $method->title;
if ( empty( $title ) ) {
// translators: %1$s is the gateway ID
$title = sprintf( esc_html_x( 'ID: %1$s (no title)', 'WooCommerce', 'uncanny-automator-pro' ), $method->id );
}
$options[ $method->id ] = $title;
}
}
$option = array(
'option_code' => $option_code,
'label' => $label,
'description' => $description,
'input_type' => 'select',
'required' => $required,
'options' => $options,
'supports_multiple_values' => false,
'options_show_id' => false,
);
return apply_filters( 'uap_option_all_wc_payment_gateways', $option );
}