WcPayWelcomePage::has_wcpay()privateWC 1.0

Check if the WooPayments payment gateway is active and set up or was at some point, or there are orders processed with it, at some moment.

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

Хуков нет.




// private - только в коде основоного (родительского) класса
$result = $this->has_wcpay(): bool;

Код WcPayWelcomePage::has_wcpay() WC 8.1.1

private function has_wcpay(): bool {
	// First, get the stored value, if it exists.
	// This way we avoid costly DB queries and API calls.
	// Basically, we only want to know if WooPayments was in use in the past.
	// Since the past can't be changed, neither can this value.
	$had_wcpay = get_option( self::HAD_WCPAY_OPTION_NAME );
	if ( false !== $had_wcpay ) {
		return $had_wcpay === 'yes';

	// We need to determine the value.
	// Start with the assumption that the store didn't have WooPayments in use.
	$had_wcpay = false;

	// We consider the store to have WooPayments if there is meaningful account data in the WooPayments account cache.
	// This implies that WooPayments was active at some point and that it was connected.
	// If WooPayments is active right now, we will not get to this point since the plugin is active check is done first.
	if ( $this->has_wcpay_account_data() ) {
		$had_wcpay = true;

	// If there is at least one order processed with WooPayments, we consider the store to have WooPayments.
	if ( false === $had_wcpay && ! empty(
				'payment_method' => 'woocommerce_payments',
				'return'         => 'ids',
				'limit'          => 1,
	) ) {
		$had_wcpay = true;

	// Store the value for future use.
	update_option( self::HAD_WCPAY_OPTION_NAME, $had_wcpay ? 'yes' : 'no' );

	return $had_wcpay;