From 849997b8d53813b7bdc88030b2449001c1cfeba1 Mon Sep 17 00:00:00 2001 From: kFrolichs Date: Tue, 13 Mar 2018 10:06:18 +0100 Subject: [PATCH] Improved code --- woocommerce-wuunder.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/woocommerce-wuunder.php b/woocommerce-wuunder.php index a7b3478..1a7513a 100644 --- a/woocommerce-wuunder.php +++ b/woocommerce-wuunder.php @@ -97,6 +97,7 @@ public function webhook() $orderId = $_REQUEST['order']; $bookingToken = $_REQUEST['token']; $data = json_decode(file_get_contents('php://input'), true); + $errorRedirect = true; $orderBookingToken = get_post_meta($orderId, '_wuunder_label_booking_token')[0]; if ($data['action'] === "shipment_booked") { @@ -108,9 +109,8 @@ public function webhook() $order = new WC_Order($orderId); $order->update_status(get_option("wc_wuunder_post_booking_status")); + $errorRedirect = false; } - } else { - wp_redirect("", 500); } } elseif ($data['action'] === "track_and_trace_updated") { // This is the 2nd webhook @@ -118,9 +118,10 @@ public function webhook() $note = __("Het pakket is aangemeld bij: ". $data["carrier_name"] ."\n De track and trace code is: ".$data["track_and_trace_code"]); $order->add_order_note($note); $order->save(); - } else { - wp_redirect("", 500); + $errorRedirect = false; } + + if($errorRedirect){wp_redirect("", 500);} } }