Hooks and Filters
The WPify Woo GoPay plugin provides hooks and filters that allow developers to customize its behavior.
Settings Filters
Section titled “Settings Filters”wpify_woo_gopay_settings
Section titled “wpify_woo_gopay_settings”Filter gateway form field settings.
apply_filters( 'wpify_woo_gopay_settings', array $settings );Parameters:
$settings(array) — Array of WooCommerce gateway form field definitions
Example — add a custom settings field:
/** * Add a custom field to GoPay gateway settings * * @param array $settings Gateway settings * @return array */function my_gopay_custom_settings( $settings ) { $settings['my_custom_field'] = array( 'title' => 'Custom Field', 'type' => 'text', 'description' => 'Custom field description', 'default' => '', );
return $settings;}add_filter( 'wpify_woo_gopay_settings', 'my_gopay_custom_settings' );Example — change the default gateway title:
/** * Change default payment gateway title * * @param array $settings Gateway settings * @return array */function my_gopay_default_title( $settings ) { $settings['title']['default'] = 'Pay with GoPay';
return $settings;}add_filter( 'wpify_woo_gopay_settings', 'my_gopay_default_title' );Payment Method Filters
Section titled “Payment Method Filters”wpify_woo_gopay_payment_method
Section titled “wpify_woo_gopay_payment_method”Filter the payment method identifier used for a payment.
apply_filters( 'wpify_woo_gopay_payment_method', string $method );Parameters:
$method(string) — Payment method identifier
Example — override the payment method:
/** * Force a specific payment method * * @param string $method Payment method * @return string */function my_gopay_force_method( $method ) { // Force card payment method return 'PAYMENT_CARD';}add_filter( 'wpify_woo_gopay_payment_method', 'my_gopay_force_method' );wpify_woo_gopay_payment_method_image
Section titled “wpify_woo_gopay_payment_method_image”Filter the image URL for a payment method icon displayed at checkout.
apply_filters( 'wpify_woo_gopay_payment_method_image', string $image_url, string $method );Parameters:
$image_url(string) — URL of the payment method image$method(string) — Payment method identifier
Example — use a custom icon for a payment method:
/** * Replace the card payment method icon * * @param string $image_url Image URL * @param string $method Payment method * @return string */function my_gopay_custom_icon( $image_url, $method ) { if ( $method === 'PAYMENT_CARD' ) { return get_stylesheet_directory_uri() . '/images/custom-card-icon.png'; }
return $image_url;}add_filter( 'wpify_woo_gopay_payment_method_image', 'my_gopay_custom_icon', 10, 2 );wpify_woo_gopay_checkout_enabled_methods
Section titled “wpify_woo_gopay_checkout_enabled_methods”Filter payment methods displayed on the GoPay payment page (main gateway only).
apply_filters( 'wpify_woo_gopay_checkout_enabled_methods', array $methods );Parameters:
$methods(array) — Array of enabled payment method identifiers
Example — allow only selected methods:
/** * Allow only card and bank transfer methods * * @param array $methods Payment methods * @return array */function my_gopay_filter_methods( $methods ) { return array_filter( $methods, function ( $method ) { return in_array( $method, [ 'PAYMENT_CARD', 'BANK_ACCOUNT' ] ); } );}add_filter( 'wpify_woo_gopay_checkout_enabled_methods', 'my_gopay_filter_methods' );Example — remove a specific method:
/** * Remove Bitcoin payment method from checkout * * @param array $methods Payment methods * @return array */function my_gopay_remove_bitcoin( $methods ) { return array_filter( $methods, function ( $method ) { return $method !== 'BITCOIN'; } );}add_filter( 'wpify_woo_gopay_checkout_enabled_methods', 'my_gopay_remove_bitcoin' );Payment Argument Filters
Section titled “Payment Argument Filters”wpify_woo_gopay_payment_args
Section titled “wpify_woo_gopay_payment_args”Filter the arguments passed to the GoPay API when creating a payment.
apply_filters( 'wpify_woo_gopay_payment_args', array $args );Parameters:
$args(array) — Array of payment arguments sent to GoPay API
Example — add custom metadata to payment:
/** * Add additional data to GoPay payment * * @param array $args Payment arguments * @return array */function my_gopay_payment_args( $args ) { $args['additional_params'][] = array( 'name' => 'custom_param', 'value' => 'custom_value', );
return $args;}add_filter( 'wpify_woo_gopay_payment_args', 'my_gopay_payment_args' );wpify_woo_gopay_recurring_payment_args
Section titled “wpify_woo_gopay_recurring_payment_args”Filter the arguments passed to the GoPay API when creating a recurring payment.
apply_filters( 'wpify_woo_gopay_recurring_payment_args', array $args );Parameters:
$args(array) — Array of recurring payment arguments sent to GoPay API
Example — modify recurring payment amount:
/** * Modify recurring payment arguments * * @param array $args Recurring payment arguments * @return array */function my_gopay_recurring_args( $args ) { // Add a custom parameter for recurring payments $args['additional_params'][] = array( 'name' => 'recurring_source', 'value' => 'woocommerce', );
return $args;}add_filter( 'wpify_woo_gopay_recurring_payment_args', 'my_gopay_recurring_args' );Gateway Filters
Section titled “Gateway Filters”wpify_woo_gopay_gateways
Section titled “wpify_woo_gopay_gateways”Filter the list of registered GoPay payment gateways. The array is a flat (numerically indexed) list of gateway class names.
apply_filters( 'wpify_woo_gopay_gateways', array $gateways );Parameters:
$gateways(array) — Numerically indexed array of gateway class names
Example — remove a gateway:
use WpifyWooGopay\Modules\WpifyWooGopay\Channels\BitcoinChannel;
/** * Remove Bitcoin gateway * * @param array $gateways Payment gateways * @return array */function my_gopay_remove_gateway( $gateways ) { return array_filter( $gateways, function ( $class ) { return $class !== BitcoinChannel::class; } );}add_filter( 'wpify_woo_gopay_gateways', 'my_gopay_remove_gateway' );Logo Filters
Section titled “Logo Filters”wpify_woo_{id}_logo
Section titled “wpify_woo_{id}_logo”Filter the logo URL for a specific gateway. Replace {id} with the gateway ID (e.g., gopay, gopay-credit-card, gopay-apple-pay).
apply_filters( 'wpify_woo_{id}_logo', string $logo_url );Parameters:
$logo_url(string) — URL of the gateway logo
Example — replace the main GoPay gateway logo:
/** * Use a custom logo for the GoPay gateway * * @param string $logo_url Logo URL * @return string */function my_gopay_custom_logo( $logo_url ) { return get_stylesheet_directory_uri() . '/images/custom-gopay-logo.svg';}add_filter( 'wpify_woo_gopay_logo', 'my_gopay_custom_logo' );Example — replace the Apple Pay gateway logo:
/** * Use a custom logo for the Apple Pay gateway * * @param string $logo_url Logo URL * @return string */function my_gopay_applepay_logo( $logo_url ) { return get_stylesheet_directory_uri() . '/images/custom-applepay-logo.svg';}add_filter( 'wpify_woo_gopay-apple-pay_logo', 'my_gopay_applepay_logo' );Where to Place Your Code
Section titled “Where to Place Your Code”You can add custom functions either in your child theme’s functions.php or use the Code Snippets plugin.