From dd902c70cc6b08fddb7c4dffa6d27d247aa041cc Mon Sep 17 00:00:00 2001 From: inpsyde-maticluznar Date: Tue, 24 Oct 2023 13:56:36 +0200 Subject: [PATCH 1/4] Set minimum expiry time to 10. --- src/Settings/General/MollieGeneralSettings.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Settings/General/MollieGeneralSettings.php b/src/Settings/General/MollieGeneralSettings.php index b0d018b9..4673e689 100644 --- a/src/Settings/General/MollieGeneralSettings.php +++ b/src/Settings/General/MollieGeneralSettings.php @@ -264,8 +264,8 @@ public function gatewayFormFields( 'mollie-payments-for-woocommerce' ) ), - 'custom_attributes' => ['step' => '1', 'min' => '0', 'max' => '526000'], - 'default' => '0', + 'custom_attributes' => ['step' => '1', 'min' => '10', 'max' => '526000'], + 'default' => '10', 'desc_tip' => false, ], ]; From bdbd3dd3c47ea215c90efde2538bb0cfe2e6573f Mon Sep 17 00:00:00 2001 From: inpsyde-maticluznar Date: Wed, 25 Oct 2023 08:48:28 +0200 Subject: [PATCH 2/4] Remove dueDate description. --- src/Settings/General/MollieGeneralSettings.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/Settings/General/MollieGeneralSettings.php b/src/Settings/General/MollieGeneralSettings.php index 4673e689..a611f7e0 100644 --- a/src/Settings/General/MollieGeneralSettings.php +++ b/src/Settings/General/MollieGeneralSettings.php @@ -258,12 +258,6 @@ public function gatewayFormFields( 'order_dueDate' => [ 'title' => sprintf(__('Expiry time', 'mollie-payments-for-woocommerce')), 'type' => 'number', - 'description' => sprintf( - __( - 'Number of MINUTES after the order will expire and will be canceled at Mollie and WooCommerce. A value of 0 means no expiry time will be considered.', - 'mollie-payments-for-woocommerce' - ) - ), 'custom_attributes' => ['step' => '1', 'min' => '10', 'max' => '526000'], 'default' => '10', 'desc_tip' => false, From 0e82e62c676252f0482bd950755d5091021cb98b Mon Sep 17 00:00:00 2001 From: inpsyde-maticluznar Date: Thu, 26 Oct 2023 12:10:13 +0200 Subject: [PATCH 3/4] Change the description, fix banktransfer and skip gateways wihout expiry --- src/Payment/PaymentModule.php | 5 +++++ src/Settings/General/MollieGeneralSettings.php | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/src/Payment/PaymentModule.php b/src/Payment/PaymentModule.php index 884a3d4b..055ada90 100644 --- a/src/Payment/PaymentModule.php +++ b/src/Payment/PaymentModule.php @@ -167,6 +167,11 @@ public function cancelOrderOnExpiryDate() foreach ($classNames as $gateway) { $gatewayName = strtolower($gateway) . '_settings'; $gatewaySettings = get_option($gatewayName); + + if (empty($gatewaySettings["activate_expiry_days_setting"]) || $gatewaySettings["activate_expiry_days_setting"] === 'no') { + continue; + } + $heldDuration = isset($gatewaySettings) && isset($gatewaySettings['order_dueDate']) ? $gatewaySettings['order_dueDate'] : 0; if ($heldDuration < 1) { diff --git a/src/Settings/General/MollieGeneralSettings.php b/src/Settings/General/MollieGeneralSettings.php index a611f7e0..d4436375 100644 --- a/src/Settings/General/MollieGeneralSettings.php +++ b/src/Settings/General/MollieGeneralSettings.php @@ -259,6 +259,12 @@ public function gatewayFormFields( 'title' => sprintf(__('Expiry time', 'mollie-payments-for-woocommerce')), 'type' => 'number', 'custom_attributes' => ['step' => '1', 'min' => '10', 'max' => '526000'], + 'description' => sprintf( + __( + 'Number of MINUTES after the order will expire and will be canceled at Mollie and WooCommerce.', + 'mollie-payments-for-woocommerce' + ) + ), 'default' => '10', 'desc_tip' => false, ], From c82b9dbeedc6028c56c0946c547892e00ec9fddf Mon Sep 17 00:00:00 2001 From: inpsyde-maticluznar Date: Thu, 26 Oct 2023 12:12:32 +0200 Subject: [PATCH 4/4] Fix wrong gateway name when canceling the order --- src/Payment/PaymentModule.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Payment/PaymentModule.php b/src/Payment/PaymentModule.php index 055ada90..6228d62b 100644 --- a/src/Payment/PaymentModule.php +++ b/src/Payment/PaymentModule.php @@ -178,7 +178,7 @@ public function cancelOrderOnExpiryDate() continue; } $heldDurationInSeconds = $heldDuration * 60; - if ($gateway === 'mollie_wc_gateway_bankTransfer') { + if ($gateway === 'Mollie_WC_Gateway_Banktransfer') { $durationInHours = absint($heldDuration) * 24; $durationInMinutes = $durationInHours * 60; $heldDurationInSeconds = $durationInMinutes * 60; @@ -479,6 +479,12 @@ public function cancelOrderAtMollie($order_id) */ public function handleExpiryDateCancelation($paymentMethods) { + add_action( + 'init', + [$this, 'cancelOrderOnExpiryDate'], + 11, + 2 + ); if (!$this->IsExpiryDateEnabled($paymentMethods)) { as_unschedule_action('mollie_woocommerce_cancel_unpaid_orders'); return;