Automattic\WooCommerce\Internal\Admin\Settings
PaymentsProviders::has_enabled_ecommerce_gateways
Check if the store has any enabled ecommerce gateways.
We exclude offline payment methods from this check.
Method of the class: PaymentsProviders{}
No Hooks.
Returns
true|false. True if the store has any enabled ecommerce gateways, false otherwise.
Usage
// private - for code of main (parent) class only $result = $this->has_enabled_ecommerce_gateways(): bool;
PaymentsProviders::has_enabled_ecommerce_gateways() PaymentsProviders::has enabled ecommerce gateways code WC 10.7.0
private function has_enabled_ecommerce_gateways(): bool {
$gateways = $this->get_payment_gateways( false ); // We want the raw gateways list.
$enabled_gateways = array_filter(
$gateways,
function ( $gateway ) {
// Filter out offline gateways.
return 'yes' === $gateway->enabled && ! $this->is_offline_payment_method( $gateway->id );
}
);
return ! empty( $enabled_gateways );
}