WC_Payment_Gateways::payment_gateway_settings_option_changedprivateWC 8.5.0

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

Метод класса: WC_Payment_Gateways{}

Хуки из метода

Возвращает

null. Ничего (null).

Использование

// private - только в коде основоного (родительского) класса
$result = $this->payment_gateway_settings_option_changed( $gateway, $value, $option, $old_value );
$gateway(WC_Payment_Gateway) (обязательный)
The gateway for which the option was added or updated.
$value(разное) (обязательный)
New value.
$option(строка) (обязательный)
Option name.
$old_value(разное)
Old value. null when called via add_option_ hook.
По умолчанию: null

Список изменений

С версии 8.5.0 Введена.

Код WC_Payment_Gateways::payment_gateway_settings_option_changed() WC 10.7.0

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 );
	}
}