From 4e7c1dd0106c759e4785d72231418e51f178a4de Mon Sep 17 00:00:00 2001 From: Garima Prachi Date: Thu, 23 Jun 2022 11:35:37 +0530 Subject: [PATCH 1/6] woo callback redirection issue fix --- woo-razorpay.php | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/woo-razorpay.php b/woo-razorpay.php index 80daacbf..5d3c0e15 100644 --- a/woo-razorpay.php +++ b/woo-razorpay.php @@ -1099,15 +1099,25 @@ function check_razorpay_response() rzpLogInfo("Called check_razorpay_response: $post_password"); - $postData = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_status FROM $wpdb->posts AS P WHERE post_type=%s AND post_password = %s", $post_type, $post_password ) ); + // $postData = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_status FROM $wpdb->posts AS P WHERE post_type=%s AND post_password = %s", $post_type, $post_password ) ); - $arrayPost = json_decode(json_encode($postData), true); + // if($postData == null) + // { + $meta_key = '_order_key'; + $postData = $wpdb->get_row( $wpdb->prepare("SELECT post_id FROM $wpdb->postmeta AS P WHERE meta_key = %s AND meta_value = %s", $meta_key, $post_password ) ); + // } + - if (!empty($arrayPost) && count($arrayPost[0]) > 0) + $postStatus = $wpdb->get_row( $wpdb->prepare("SELECT post_status FROM $wpdb->posts AS P WHERE post_type=%s and ID=%s", $post_type, $postData->post_id) ); + + $arrayPost = json_decode(json_encode($postData), true); + if (!empty($arrayPost) && $arrayPost != null) { - $orderId = $postData[0]->ID; + // $orderId = $postData[0]->ID; + + $orderId = $postData->post_id; - if($postData[0]->post_status == 'draft') + if($postStatus == 'draft') { updateOrderStatus($orderId, 'wc-pending'); } From a9efd0c28b81a1ae10299a97be368a91ef55c5c1 Mon Sep 17 00:00:00 2001 From: garimaprachi <105697320+garimaprachi@users.noreply.github.com> Date: Thu, 23 Jun 2022 16:40:30 +0530 Subject: [PATCH 2/6] Update woo-razorpay.php --- woo-razorpay.php | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/woo-razorpay.php b/woo-razorpay.php index 5d3c0e15..bc153ab6 100644 --- a/woo-razorpay.php +++ b/woo-razorpay.php @@ -1099,25 +1099,20 @@ function check_razorpay_response() rzpLogInfo("Called check_razorpay_response: $post_password"); - // $postData = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_status FROM $wpdb->posts AS P WHERE post_type=%s AND post_password = %s", $post_type, $post_password ) ); - - // if($postData == null) - // { - $meta_key = '_order_key'; - $postData = $wpdb->get_row( $wpdb->prepare("SELECT post_id FROM $wpdb->postmeta AS P WHERE meta_key = %s AND meta_value = %s", $meta_key, $post_password ) ); - // } + $meta_key = '_order_key'; + + $postData = $wpdb->get_row( $wpdb->prepare("SELECT post_id FROM $wpdb->postmeta AS P WHERE meta_key = %s AND meta_value = %s", $meta_key, $post_password ) ); - $postStatus = $wpdb->get_row( $wpdb->prepare("SELECT post_status FROM $wpdb->posts AS P WHERE post_type=%s and ID=%s", $post_type, $postData->post_id) ); $arrayPost = json_decode(json_encode($postData), true); - if (!empty($arrayPost) && $arrayPost != null) + if (!empty($arrayPost) and + $arrayPost != null) { - // $orderId = $postData[0]->ID; $orderId = $postData->post_id; - if($postStatus == 'draft') + if($postStatus === 'draft') { updateOrderStatus($orderId, 'wc-pending'); } From d4f0582081f39e8d639c1be6344085eee147ed74 Mon Sep 17 00:00:00 2001 From: garimaprachi <105697320+garimaprachi@users.noreply.github.com> Date: Thu, 23 Jun 2022 16:59:23 +0530 Subject: [PATCH 3/6] Update woo-razorpay.php --- woo-razorpay.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/woo-razorpay.php b/woo-razorpay.php index bc153ab6..4e941a73 100644 --- a/woo-razorpay.php +++ b/woo-razorpay.php @@ -1106,10 +1106,9 @@ function check_razorpay_response() $postStatus = $wpdb->get_row( $wpdb->prepare("SELECT post_status FROM $wpdb->posts AS P WHERE post_type=%s and ID=%s", $post_type, $postData->post_id) ); $arrayPost = json_decode(json_encode($postData), true); - if (!empty($arrayPost) and + if (!empty($arrayPost) and $arrayPost != null) { - $orderId = $postData->post_id; if($postStatus === 'draft') From 2180ce5e78ccdf2e693cad55a750072342d2f8ef Mon Sep 17 00:00:00 2001 From: garimaprachi <105697320+garimaprachi@users.noreply.github.com> Date: Thu, 23 Jun 2022 18:32:32 +0530 Subject: [PATCH 4/6] Update woo-razorpay.php --- woo-razorpay.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/woo-razorpay.php b/woo-razorpay.php index 4e941a73..ef594f90 100644 --- a/woo-razorpay.php +++ b/woo-razorpay.php @@ -1101,17 +1101,17 @@ function check_razorpay_response() $meta_key = '_order_key'; - $postData = $wpdb->get_row( $wpdb->prepare("SELECT post_id FROM $wpdb->postmeta AS P WHERE meta_key = %s AND meta_value = %s", $meta_key, $post_password ) ); + $postMetaData = $wpdb->get_row( $wpdb->prepare("SELECT post_id FROM $wpdb->postmeta AS P WHERE meta_key = %s AND meta_value = %s", $meta_key, $post_password ) ); - $postStatus = $wpdb->get_row( $wpdb->prepare("SELECT post_status FROM $wpdb->posts AS P WHERE post_type=%s and ID=%s", $post_type, $postData->post_id) ); + $postData = $wpdb->get_row( $wpdb->prepare("SELECT post_status FROM $wpdb->posts AS P WHERE post_type=%s and ID=%s", $post_type, $postMetaData->post_id) ); - $arrayPost = json_decode(json_encode($postData), true); + $arrayPost = json_decode(json_encode($postMetaData), true); if (!empty($arrayPost) and $arrayPost != null) { - $orderId = $postData->post_id; + $orderId = $postMetaData->post_id; - if($postStatus === 'draft') + if($postData === 'draft') { updateOrderStatus($orderId, 'wc-pending'); } From 84eafc606bdf5d88b92b8791f25dcf767d4dbe3b Mon Sep 17 00:00:00 2001 From: garimaprachi <105697320+garimaprachi@users.noreply.github.com> Date: Thu, 23 Jun 2022 18:40:05 +0530 Subject: [PATCH 5/6] Update woo-razorpay.php --- woo-razorpay.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/woo-razorpay.php b/woo-razorpay.php index ef594f90..f3708fbc 100644 --- a/woo-razorpay.php +++ b/woo-razorpay.php @@ -1106,12 +1106,13 @@ function check_razorpay_response() $postData = $wpdb->get_row( $wpdb->prepare("SELECT post_status FROM $wpdb->posts AS P WHERE post_type=%s and ID=%s", $post_type, $postMetaData->post_id) ); $arrayPost = json_decode(json_encode($postMetaData), true); + if (!empty($arrayPost) and $arrayPost != null) { $orderId = $postMetaData->post_id; - if($postData === 'draft') + if($postData->post_status === 'draft') { updateOrderStatus($orderId, 'wc-pending'); } From 713149a54b20d47a1eb76666dee19d5e86c9d02d Mon Sep 17 00:00:00 2001 From: garimaprachi <105697320+garimaprachi@users.noreply.github.com> Date: Fri, 24 Jun 2022 15:59:17 +0530 Subject: [PATCH 6/6] Update woo-razorpay.php --- woo-razorpay.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/woo-razorpay.php b/woo-razorpay.php index f3708fbc..bd1f07ea 100644 --- a/woo-razorpay.php +++ b/woo-razorpay.php @@ -1112,7 +1112,7 @@ function check_razorpay_response() { $orderId = $postMetaData->post_id; - if($postData->post_status === 'draft') + if ($postData->post_status === 'draft') { updateOrderStatus($orderId, 'wc-pending'); }