From cdd5c41f0644741c080a3465aadb864f4d288df2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20Kj=C3=A6r=20Rasmussen?= Date: Thu, 14 Mar 2024 16:54:23 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Handle=20if=20gateway=20is=20not?= =?UTF-8?q?=20activated?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/WoocommerceEconomic.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/WoocommerceEconomic.php b/src/WoocommerceEconomic.php index 7f59321..caf875c 100755 --- a/src/WoocommerceEconomic.php +++ b/src/WoocommerceEconomic.php @@ -20,6 +20,9 @@ public static function init(): void public static function registerGateway($gateways): array { + if (! class_exists('WC_Payment_Gateway')) { + return $gateways; + } $gateways[] = \WC_Gateway_Economic_Invoice::class; return $gateways; @@ -27,6 +30,9 @@ public static function registerGateway($gateways): array public static function requireGateway(): void { - require_once __DIR__.'/Woocommerce/WC_Gateway_Economic_Invoice.php'; + if (! class_exists('WC_Payment_Gateway')) { + return; + } + require_once __DIR__ . '/Woocommerce/WC_Gateway_Economic_Invoice.php'; } }