From 09149f18797afd4b38c9102fe8c4f9f6dce11812 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20H=C3=BCsken?= Date: Wed, 18 Dec 2024 14:21:57 +0100 Subject: [PATCH] Not display Button Gateway when only a free trial product is in cart --- .../src/Gateway/CardButtonGateway.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/modules/ppcp-wc-gateway/src/Gateway/CardButtonGateway.php b/modules/ppcp-wc-gateway/src/Gateway/CardButtonGateway.php index 3ba41da15..ffb0fe55c 100644 --- a/modules/ppcp-wc-gateway/src/Gateway/CardButtonGateway.php +++ b/modules/ppcp-wc-gateway/src/Gateway/CardButtonGateway.php @@ -362,4 +362,19 @@ class CardButtonGateway extends \WC_Payment_Gateway { protected function settings_renderer(): SettingsRenderer { return $this->settings_renderer; } + + /** + * Determines if the Gateway is available for use. + * + * @return bool + */ + public function is_available(): bool { + $is_available = parent::is_available(); + + if ( $is_available && $this->is_free_trial_cart() ) { + $is_available = false; + } + + return $is_available; + } }