24 lines
744 B
PHP
24 lines
744 B
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace Esun\Reward\Block\Order;
|
|
|
|
use Magento\Framework\DataObject;
|
|
use Magento\Framework\View\Element\Template;
|
|
|
|
class RewardTotals extends Template
|
|
{
|
|
public function initTotals(): self
|
|
{
|
|
$parent = $this->getParentBlock(); $source = $parent?->getSource();
|
|
if ($parent && $source && (float)$source->getData('reward_discount_amount') > 0) {
|
|
$parent->addTotal(new DataObject([
|
|
'code' => 'reward_discount',
|
|
'value' => -(float)$source->getData('reward_discount_amount'),
|
|
'label' => __('Points Discount (%1 points)', (int)$source->getData('reward_points_used'))
|
|
]), 'discount');
|
|
}
|
|
return $this;
|
|
}
|
|
}
|