WC_Payment_Gateways::was_gateway_disabledprivateWC 1.0

Determines from changes in settings if a gateway was disabled.

Method of the class: WC_Payment_Gateways{}

No Hooks.

Returns

true|false. Whether the gateway was disabled or not.

Usage

// private - for code of main (parent) class only
$result = $this->was_gateway_disabled( $value, $old_value );
$value(array) (required)
New value.
$old_value(array)
Old value.
Default: null

WC_Payment_Gateways::was_gateway_disabled() code WC 10.5.0

private function was_gateway_disabled( $value, $old_value = null ) {
	if ( null === $old_value ) {
		// There was no old value, so this is a new option.
		// We don't consider a new option for determining if a gateway was disabled.
		return false;
	}

	// There was an old value, so this is an update.
	if (
		ArrayUtil::get_value_or_default( $value, 'enabled' ) === 'no' &&
		ArrayUtil::get_value_or_default( $old_value, 'enabled' ) !== 'no' ) {
		return true;
	}

	return false;
}