diff --git a/src/Payment/PaymentModule.php b/src/Payment/PaymentModule.php index 440968aa..d7c92734 100644 --- a/src/Payment/PaymentModule.php +++ b/src/Payment/PaymentModule.php @@ -167,13 +167,18 @@ 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) { 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; @@ -474,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; diff --git a/src/Settings/General/MollieGeneralSettings.php b/src/Settings/General/MollieGeneralSettings.php index 7ac6b9d7..a97d4a38 100644 --- a/src/Settings/General/MollieGeneralSettings.php +++ b/src/Settings/General/MollieGeneralSettings.php @@ -258,14 +258,14 @@ public function gatewayFormFields( 'order_dueDate' => [ '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. A value of 0 means no expiry time will be considered.', + 'Number of MINUTES after the order will expire and will be canceled at Mollie and WooCommerce.', 'mollie-payments-for-woocommerce' ) ), - 'custom_attributes' => ['step' => '1', 'min' => '0', 'max' => '526000'], - 'default' => '0', + 'default' => '10', 'desc_tip' => false, ], ];