33 if (empty(
$data[
'comment']) &&
$data[
'status'] ==
$order->getDataByKey(
'status')) {
34 throw new \Magento\Framework\Exception\LocalizedException(
35 __(
'The comment is missing. Enter and try again.')
39 $notify = isset(
$data[
'is_customer_notified']) ?
$data[
'is_customer_notified'] :
false;
40 $visible = isset(
$data[
'is_visible_on_front']) ?
$data[
'is_visible_on_front'] :
false;
42 $history =
$order->addStatusHistoryComment(
$data[
'comment'],
$data[
'status']);
43 $history->setIsVisibleOnFront($visible);
44 $history->setIsCustomerNotified($notify);
47 $comment = trim(strip_tags(
$data[
'comment']));
51 $orderCommentSender = $this->_objectManager
54 $orderCommentSender->send(
$order, $notify, $comment);
56 return $this->resultPageFactory->create();
58 $response = [
'error' =>
true,
'message' => $e->getMessage()];
59 }
catch (\Exception $e) {
60 $response = [
'error' =>
true,
'message' =>
__(
'We cannot add order history.')];
63 $resultJson = $this->resultJsonFactory->create();
68 return $this->resultRedirectFactory->create()->setPath(
'sales/*/');