WC_Payment_Gateways::payment_gateway_settings_option_changedprivateWC 8.5.0

Callback for when a gateway settings option was added or updated.

Method of the class: WC_Payment_Gateways{}

Hooks from the method

Returns

null. Nothing (null).

Usage

// private - for code of main (parent) class only
$result = $this->payment_gateway_settings_option_changed( $gateway, $value, $option, $old_value );
$gateway(WC_Payment_Gateway) (required)
The gateway for which the option was added or updated.
$value(mixed) (required)
New value.
$option(string) (required)
Option name.
$old_value(mixed)
Old value. null when called via add_option_ hook.
Default: null

Changelog

Since 8.5.0 Introduced.

WC_Payment_Gateways::payment_gateway_settings_option_changed() code WC 10.8.1

private function payment_gateway_settings_option_changed( $gateway, $value, $option, $old_value = null ) {
	if ( $this->was_gateway_enabled( $value, $old_value ) ) {
		$logger = wc_get_container()->get( LegacyProxy::class )->call_function( 'wc_get_logger' );
		$logger->info( sprintf( 'Payment gateway enabled: "%s"', $gateway->get_method_title() ) );

		/**
		 * Fires when a payment gateway has been enabled.
		 *
		 * Used by WC_Email_Admin_Payment_Gateway_Enabled to send an admin notification email.
		 * This action is registered as a transactional email action in WC_Emails::init_transactional_emails(),
		 * which ensures WC_Emails is instantiated before the _notification variant is fired.
		 *
		 * @param WC_Payment_Gateway $gateway The gateway that was enabled.
		 *
		 * @since 10.7.0
		 */
		do_action( 'woocommerce_payment_gateway_enabled', $gateway );

		// Track the gateway enable.
		$this->record_gateway_event( 'enable', $gateway );
	}

	if ( $this->was_gateway_disabled( $value, $old_value ) ) {
		// This is a change to a payment gateway's settings and it was just disabled. Let's track it.
		$this->record_gateway_event( 'disable', $gateway );
	}
}