0

app\design\frontend\Theme\name\Magento_Sales\templates\email\creditmemo\items.phtml

Below script showing total related details in refund email template.

<tfoot class="order-totals">
 <?= $block->getChildHtml('creditmemo_totals') ?>
</tfoot>

How can i change text Grand Total to Refund Total? enter image description here

1 Answer 1

0

You need to do this things.

  1. Overide _initTotals() function of this file

Magento\Sales\Block\Order\Creditmemo\Totals.php

into your custom extension.

  1. Into overided file, add below code at last into above function.

    public function _initTotals()
    {
    parent::_initTotals();
    
    $parent = $this->getParentBlock();
    $source = $parent->getSource();
    
    $this->removeTotal('base_grandtotal');
    if ((double)$this->getSource()->getAdjustmentPositive()) {
        $total = new \Magento\Framework\DataObject(
            [
                'code' => 'adjustment_positive',
                'value' => $this->getSource()->getAdjustmentPositive(),
                'label' => __('Adjustment Refund'),
            ]
        );
        $this->addTotal($total);
    }
    if ((double)$this->getSource()->getAdjustmentNegative()) {
        $total = new \Magento\Framework\DataObject(
            [
                'code' => 'adjustment_negative',
                'value' => $this->getSource()->getAdjustmentNegative(),
                'label' => __('Adjustment Fee'),
            ]
        );
        $this->addTotal($total);
    }
    
    $this->removeTotal('grand_total');
    $total = new \Magento\Framework\DataObject(
                [
                    'code' => 'grand_total',
                    'field' => 'grand_total',
                    'strong' => true, 
                    'value' => $source->getGrandTotal(),
                    'label' => __('Refund Total'),
                ]
            );
            $parent->addTotal($total);
    return $this;
    }
    
4
  • Now in email template it's showing this message in email body. : We're sorry, an error has occurred while generating this content. Dec 26, 2018 at 6:48
  • try to check that, in log files, does it show anything? Dec 26, 2018 at 10:14
  • not showing any error related to this changes. Dec 26, 2018 at 11:15
  • I update answer with entire code of that function. Kindly check. Dec 27, 2018 at 14:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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