1

I want Reward Redeemed and and Earned Points in order_new.html Email template page in Total section and E Gift Card Reedemed Data also required. For that I Overide this file in my theme:

/var/www/html/aldo/app/design/frontend/vendor/theme/Magento_Sales/email/order_new.html

/var/www/html/magento/app/design/frontend/<vendor>/<theme>/Magento_Sales/templates/order/totals.phtml.

<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

/**
 * @var $block \Magento\Sales\Block\Order\Totals
 * @see \Magento\Sales\Block\Order\Totals
 */
$_totals = $block->getTotals();
$_order = $block->getOrder();
$demoData = "";
?>

<table align="right" cellspacing="0" cellpadding="0" border="0" width="300px" style="border:1px solid #EAEAEA;">

    <tr>
        <th  align="right"><?= /* @escapeNotVerified */  __('Promo Discount') ?></th>
        <td>  <?= /* @escapeNotVerified */  $_order->getBaseDiscountAmount() ?></td>
    </tr>
    <tr>
        <th  align="right"><?= /* @escapeNotVerified */  __('Shipping') ?></th>
        <td><?= /* @escapeNotVerified */  $_order->getShippingAmount() ?></td>
    </tr>
    <tr>
        <th  align="right"><?= /* @escapeNotVerified */  __('Subtotal') ?></th>
        <td>  <?= /* @escapeNotVerified */  $_order->getSubtotal() ?></td>
    </tr>s
    <tr>
        <th  align="right"><?= /* @escapeNotVerified */  __('GST incl') ?></th>
        <td>  <?= /* @escapeNotVerified */  $_order->getTaxAmount() ?></td>
    </tr>
    <tr>
        <th  align="right"><?= /* @escapeNotVerified */  __('e-Gift Card Redeemed') ?></th>
        <td>  <?= /* @escapeNotVerified */ $demoData   ?></td>
    </tr>
    <tr>
        <th  align="right"><?= /* @escapeNotVerified */  __('Points Earned') ?></th>
        <td><?= /* @escapeNotVerified */  $demoData ?></td>
    </tr>
    <tr>
        <th align="right"><?= /* @escapeNotVerified */  __('Points Redeemed') ?></th>
        <td>  <?= /* @escapeNotVerified */  $demoData ?></td>
    </tr>
    <tr>
        <th  align="right"><?= /* @escapeNotVerified */  __('Total') ?></th>
        <td><?= /* @escapeNotVerified */  $_order->getGrandTotal() ?></td>
    </tr>
</table>

1 Answer 1

2
**Reward Point Description**

Magento’s reward points system gives you the ability to implement unique programs that drive customer engagement and promote customer loyalty. Points can be awarded for a wide range of transaction and customer activities, and the configuration can be set to control the point allotment, balance, and expiration. Customers can redeem points toward purchases, based on the conversion rate that you establish between reward points and currency.

Orders placed with reward points can be refunded to the reward points balance up to the amount redeemed in the order. On the New Credit Memo page, the amount of points to be applied to the customer’s balance can be entered. By default, the field contains the full amount of points that were used in the order.

This Funcationality is Availabel in Magento Commerce Cloud

Coming to Main point of this question, we need to simply modifiy this block in our custom module and add this block in layout file

Vendor/Sales/Block/Order/Email/Items.php

<?php
namespace Vendor\Sales\Block\Order\Email;

use Magento\Framework\View\Element\Template\Context;
use Magento\Reward\Model\ResourceModel\Reward\History\CollectionFactory;
use Magento\Framework\Pricing\Helper\Data;

class Items extends \Magento\Sales\Block\Order\Email\Items
{

    protected $collection;

    public $pricingHelper;

    public function __construct(
        Context $context,
        CollectionFactory $collectionFactory,
        Data $pricingHelper,
        array $data = []
    ) {
        $this->collection = $collectionFactory;
        $this->pricingHelper = $pricingHelper;
        parent::__construct($context, $data);
    }

    public function getPointsEarnedData($customerId)
    {
        return $this->collection->create()->addCustomerFilter($customerId)->getLastItem()->getPointsDelta();
    }
}

You need to intialize this collection factory in your costruct function use Magento\Reward\Model\ResourceModel\Reward\History\CollectionFactory;

From template you have to pass $customerId, when you call the **$block->getPointsEarnedData($customerId);** function in your template file.

And you will get your desire result Finally.

Thanks @RAKESH KUMAR ROY

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.