0

I need to show order comment in file

vendor/magento/module-sales/view/frontend/templates/order/history.phtml

I tried to use the code:

<?php $_history = $_order->getVisibleStatusHistory() ?>
<?php if (count($_history)): ?>
<div class="order-additional order-comments">
<dl class="order-about">
<?php foreach ($_history as $_historyItem): ?>
<dd>
<span class='lowcase'><?php echo $_historyItem->getComment()?></span>
</dd>
<?php endforeach; ?>
</dl>
</div>
<?php endif?>

Did not work.

  • could you please add $_order object code ? – Pawan Oct 25 '19 at 3:51
0

First try with this code of Object Manager, if you get value converts it into Dependency Injection. Code are:

$orderId = $orderId;
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$order = $objectManager->create('\Magento\Sales\Model\Order')->load($orderId);
$order->addStatusHistoryComment('This comment is programatically added to last order in this Magento setup');
$order->save();

Hope this will help You !!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.