Automattic\WooCommerce\Admin\Features\OnboardingTasks\Tasks

AdditionalPayments::can_view()publicWC 1.0

Task visibility.

Method of the class: AdditionalPayments{}

No Hooks.

Return

true|false.

Usage

$AdditionalPayments = new AdditionalPayments();
$AdditionalPayments->can_view();

AdditionalPayments::can_view() code WC 9.6.1

public function can_view() {
	// Go ahead if either of the features are enabled.
	// If the payment-gateway-suggestions are disabled,
	// we are still good to go because we can use the default suggestions.
	if ( ! Features::is_enabled( 'reactify-classic-payments-settings' ) &&
		! Features::is_enabled( 'payment-gateway-suggestions' ) ) {
		// Hide task if both features are not enabled.
		return false;
	}

	if ( null !== $this->can_view_result ) {
		return $this->can_view_result;
	}

	// Always show task if the React-based Payments settings page is enabled and
	// there are any gateways enabled (i.e. the Payments task is complete).
	if ( Features::is_enabled( 'reactify-classic-payments-settings' ) &&
		self::has_gateways() ) {
		return true;
	}

	// Show task if WooPayments is connected or if there are any suggested gateways in other category enabled.
	// Note: For now, we rely on the old Payment Gateways Suggestions lists to determine the visibility of this task.
	// This will need to be updated to use the new Payment Extension Suggestions/ Payments Providers system.
	$this->can_view_result = (
		WooCommercePayments::is_connected() ||
		self::has_enabled_other_category_gateways()
	);

	// Early return if task is not visible.
	if ( ! $this->can_view_result ) {
		return false;
	}

	// Show task if there are any suggested gateways in additional category.
	$this->can_view_result = ! empty( self::get_suggestion_gateways( 'category_additional' ) );

	return $this->can_view_result;
}