Skip to content

Hooks and Filters

The WPify Woo ThePay plugin provides hooks and filters that allow developers to customize its behavior.

Filter gateway form field settings.

apply_filters( 'wpify_woo_thepay_settings', array $settings );

Parameters:

  • $settings (array) — Array of WooCommerce gateway form field definitions

Example — add a custom settings field:

/**
* Add a custom field to ThePay gateway settings
*
* @param array $settings Gateway settings
* @return array
*/
function my_thepay_custom_settings( $settings ) {
$settings['my_custom_field'] = array(
'title' => 'Custom Field',
'type' => 'text',
'description' => 'Custom field description',
'default' => '',
);
return $settings;
}
add_filter( 'wpify_woo_thepay_settings', 'my_thepay_custom_settings' );

Example — change the default gateway title:

/**
* Change default payment gateway title
*
* @param array $settings Gateway settings
* @return array
*/
function my_thepay_default_title( $settings ) {
$settings['title']['default'] = 'Pay with ThePay';
return $settings;
}
add_filter( 'wpify_woo_thepay_settings', 'my_thepay_default_title' );

Filter payment methods displayed on the ThePay payment page (main gateway only).

apply_filters( 'wpify_woo_thepay_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_thepay_filter_methods( $methods ) {
return array_filter( $methods, function ( $method ) {
return in_array( $method, [ 'card', 'platba24', 'csob' ] );
} );
}
add_filter( 'wpify_woo_thepay_checkout_enabled_methods', 'my_thepay_filter_methods' );

Example — remove a specific method:

/**
* Remove Bitcoin payment method from checkout
*
* @param array $methods Payment methods
* @return array
*/
function my_thepay_remove_bitcoin( $methods ) {
return array_filter( $methods, function ( $method ) {
return $method !== 'bitcoin';
} );
}
add_filter( 'wpify_woo_thepay_checkout_enabled_methods', 'my_thepay_remove_bitcoin' );

Filter the list of registered ThePay payment gateways. The array is a flat (numerically indexed) list of gateway class names.

apply_filters( 'wpify_woo_thepay_gateways', array $gateways );

Parameters:

  • $gateways (array) — Numerically indexed array of gateway class names

Example — remove a gateway:

use WpifyWooThepay\Modules\WpifyWooThepay\Channels\BitcoinChannel;
/**
* Remove Bitcoin gateway
*
* @param array $gateways Payment gateways
* @return array
*/
function my_thepay_remove_gateway( $gateways ) {
return array_filter( $gateways, function ( $class ) {
return $class !== BitcoinChannel::class;
} );
}
add_filter( 'wpify_woo_thepay_gateways', 'my_thepay_remove_gateway' );

wpify_woo_thepay_payment_status_notification

Section titled “wpify_woo_thepay_payment_status_notification”

Triggered when a payment status notification is received from ThePay. Allows you to react to payment status changes (successful payment, refund, etc.).

do_action( 'wpify_woo_thepay_payment_status_notification', $status, $order, $payment );

Parameters:

  • $status (string) — Payment status (e.g., paid, preauthorized, expired, refunded)
  • $order (WC_Order) — WooCommerce order object
  • $payment (Payment) — ThePay API payment object

Example — custom logic after successful payment:

/**
* Send notification after successful payment
*
* @param string $status Payment status
* @param WC_Order $order Order
* @param object $payment ThePay payment object
*/
function my_thepay_payment_notification( $status, $order, $payment ) {
if ( $status === 'paid' ) {
// Send custom email notification
wp_mail(
'admin@example.com',
'Payment received for order #' . $order->get_order_number(),
'Order #' . $order->get_order_number() . ' has been paid.'
);
}
}
add_action( 'wpify_woo_thepay_payment_status_notification', 'my_thepay_payment_notification', 10, 3 );

Example — log payment statuses:

/**
* Log payment status changes to WooCommerce log
*
* @param string $status Payment status
* @param WC_Order $order Order
* @param object $payment ThePay payment object
*/
function my_thepay_log_status( $status, $order, $payment ) {
$logger = wc_get_logger();
$logger->info( sprintf(
'ThePay notification: order #%s, status: %s',
$order->get_order_number(),
$status
), [ 'source' => 'thepay-custom' ] );
}
add_action( 'wpify_woo_thepay_payment_status_notification', 'my_thepay_log_status', 10, 3 );

You can add custom functions either in your child theme’s functions.php or use the Code Snippets plugin.