im work on print order to print order comment when we do print order from front end,
My Orders->Print Order
when click on Print Order the same comment print on PDF, for that i have created Module using override core files
registration.php, module.xml
Here is a code,
di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
<preference for="Magento\Sales\Model\Order\Pdf\Invoice" type="Tms\Printcomment\Model\Rewrite\Order\Pdf\Invoice" />
</config>
Tms\Printcomment\Model\Rewrite\Order\Pdf\Invoice.php
app/code/Tms/Printcomment/view/frontend/templates/order/order_comments.phtml
<?php $_history = $block->getOrder()->getVisibleStatusHistory() ?>
<?php if (!empty($_history)) : ?>
<div class="block block-order-details-comments">
<div class="block-title"><strong><?= $block->escapeHtml(__('About Your Order')) ?></strong></div>
<div class="block-content">
<dl class="order-comments">
<?php foreach ($_history as $_historyItem) : ?>
<dt class="comment-date">
<?= /* @noEscape */
$block->formatDate($_historyItem->getCreatedAt(), \IntlDateFormatter::MEDIUM, true) ?>
</dt>
<dd class="comment-content"><?= $block->escapeHtml($_historyItem->getComment()) ?></dd>
<?php endforeach; ?>
</dl>
</div>
</div>
<?php endif; ?>
app/code/Tms/Printcomment/view/frontend/layout/sales_order_print.xml
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<!-- <referenceBlock name="additional.product.info">
<block class="Tms\Printcomment\Order\View"
name="order.comments"
template="Namespace_Sales::order/order_comments.phtml"
cacheable="false" />
</referenceBlock> -->
<!-- <block class="Magento\Sales\Block\Order\View" name="order.comments" template="Magento_Sales::order/order_comments.phtml" />-->
<referenceBlock name="order.comments" template="Tms_Printcomment::order/order_comments.phtml" />
</body>
</page>
But its not work, comment not print in PDF, what shoud I do wrong? please help me on this