function invokeCancelFulfillmentOrder(FBAOutboundServiceMWS_Interface $service, $request, $order_id, $FBAOrderID) { $order = new WC_Order($order_id); try { $response = $service->cancelFulfillmentOrder($request); // cancel fulfillment does not return anything. $level = "Neutral"; $category = "Order"; $title = "FBA Cancel Order - Woo ID:" . $order_id; $cancel_message = "Cancellation request sent to Amazon for FBAOrder id: " . $FBAOrderID; $order->add_order_note($cancel_message, 0); AmzFBA_Woo_Log($level, $category, $title, $cancel_message); } catch (FBAOutboundServiceMWS_Exception $ex) { // echo("XML: " . $ex->getXML() . "\n"); $level = "Bad"; $category = "Order"; $title = "Cancel FBA order - Order ID:" . $order_id; $info = "Caught Exception: " . $ex->getMessage() . " | Response Status Code: " . $ex->getStatusCode() . " | Error Code: " . $ex->getErrorCode() . " | Error Type: " . $ex->getErrorType() . " | Request ID: " . $ex->getRequestId(); $order->add_order_note("FBA order cancellation failed. Check logs", 0); AmzFBA_Woo_Log($level, $category, $title, $info); SendErrorEmail("Order", $info); } catch (Exception $e) { $order->add_order_note("FBA order cancellation failed. Check logs", 0); HandleGenericException("Order", $e); } }