From e63fb521b5eb8b394b0620019b8f3864cfc4e8bb Mon Sep 17 00:00:00 2001 From: Djalel Date: Fri, 29 Nov 2024 11:04:26 +0000 Subject: [PATCH 1/3] SMP-3022 : Using hook to get the order id --- src/Gateway/PayplugGateway.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Gateway/PayplugGateway.php b/src/Gateway/PayplugGateway.php index 19d6e9a6..e85d529b 100644 --- a/src/Gateway/PayplugGateway.php +++ b/src/Gateway/PayplugGateway.php @@ -275,6 +275,8 @@ public function customize_gateway_title($total_rows, $order) */ public function validate_payment($id = null, $save_request = true, $ipn = false) { + global $wp; + if(!$ipn){ if (!is_wc_endpoint_url('order-received') || (empty($_GET['key']) && empty($id)) ) { return; @@ -288,6 +290,16 @@ public function validate_payment($id = null, $save_request = true, $ipn = false) $order_id = (int) $id; } + if (empty($order_id)) { + $order_id = apply_filters( + 'woocommerce_thankyou_order_id', + absint($wp->query_vars['order-received']) + ); + if (empty($order_id)) { + return; + } + } + if (empty($order_id)) { $order_id = wc_get_order_id_by_order_key(wc_clean( (!empty($_GET['key']) ? $_GET['key'] : $id) ) ); if (empty($order_id)) { From 80edd884a5deaacec82b35feb1e7d15d6cd45046 Mon Sep 17 00:00:00 2001 From: Djalel Date: Fri, 29 Nov 2024 12:55:17 +0000 Subject: [PATCH 2/3] SMP-3022 : remove blocking return --- src/Gateway/PayplugGateway.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Gateway/PayplugGateway.php b/src/Gateway/PayplugGateway.php index e85d529b..a3d2988e 100644 --- a/src/Gateway/PayplugGateway.php +++ b/src/Gateway/PayplugGateway.php @@ -295,9 +295,6 @@ public function validate_payment($id = null, $save_request = true, $ipn = false) 'woocommerce_thankyou_order_id', absint($wp->query_vars['order-received']) ); - if (empty($order_id)) { - return; - } } if (empty($order_id)) { From a0c10abacdb4f69d279c7dc8477b6913e48321d8 Mon Sep 17 00:00:00 2001 From: Djalel Date: Fri, 29 Nov 2024 14:59:03 +0000 Subject: [PATCH 3/3] SMP-3022 : fail safe for $id --- src/Gateway/PayplugGateway.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Gateway/PayplugGateway.php b/src/Gateway/PayplugGateway.php index a3d2988e..5a1302c9 100644 --- a/src/Gateway/PayplugGateway.php +++ b/src/Gateway/PayplugGateway.php @@ -298,10 +298,17 @@ public function validate_payment($id = null, $save_request = true, $ipn = false) } if (empty($order_id)) { - $order_id = wc_get_order_id_by_order_key(wc_clean( (!empty($_GET['key']) ? $_GET['key'] : $id) ) ); - if (empty($order_id)) { + + if (empty($_GET['key']) && empty($id) && !is_object($id)) { return; } + + $order_id = wc_get_order_id_by_order_key(wc_clean( (!empty($_GET['key']) ? $_GET['key'] : (int) $id) ) ); + + } + + if (empty($order_id)) { + return; } $order = wc_get_order($order_id);