Skip to content

Commit

Permalink
Improved code
Browse files Browse the repository at this point in the history
  • Loading branch information
kFrolichs committed Mar 13, 2018
1 parent 7c4ce72 commit 849997b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions woocommerce-wuunder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand All @@ -108,19 +109,19 @@ 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
$order = wc_get_order($orderId);
$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);}
}

}
Expand Down

0 comments on commit 849997b

Please sign in to comment.