Automattic\WooCommerce\Admin\Features\PaymentGatewaySuggestions

DefaultPaymentGateways::get_rules_for_wcpay_connected()public staticWC 1.0

Get default rules for WooPayments being connected or not.

This does not include the check for the WooPayments plugin to be active.

Method of the class: DefaultPaymentGateways{}

No Hooks.

Return

Object. Rules to match.

Usage

$result = DefaultPaymentGateways::get_rules_for_wcpay_connected( $should_be );
$should_be(true|false) (required)
Whether WooPayments should be connected.

DefaultPaymentGateways::get_rules_for_wcpay_connected() code WC 9.7.1

public static function get_rules_for_wcpay_connected( $should_be ) {
	return (object) array(
		'type'         => 'option',
		'transformers' => array(
			// Extract only the 'data' key from the option.
			(object) array(
				'use'       => 'dot_notation',
				'arguments' => (object) array(
					'path' => 'data',
				),
			),
			// Extract the keys from the data array.
			(object) array(
				'use' => 'array_keys',
			),
		),
		'option_name'  => 'wcpay_account_data',
		// The rule will be look for the 'account_id' key in the account data array.
		'operation'    => $should_be ? 'contains' : '!contains',
		'value'        => 'account_id',
		'default'      => array(),
	);
}