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{}

No Hooks.

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.5.0

private function payment_gateway_settings_option_changed( $gateway, $value, $option, $old_value = null ) {
	if ( $this->was_gateway_enabled( $value, $old_value ) ) {
		// This is a change to a payment gateway's settings and it was just enabled. Let's send an email to the admin.
		// "untitled" shouldn't happen, but just in case.
		$this->notify_admin_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 );
	}
}