b374k
m1n1 1.01
Apache/2.4.41 (Ubuntu)
Linux vmi616275.contaboserver.net 5.4.0-84-generic #94-Ubuntu SMP Thu Aug 26 20:27:37 UTC 2021 x86_64
uid=33(www-data) gid=33(www-data) groups=33(www-data)
server ip : 62.171.164.128 | your ip : 127.0.0.1
safemode OFF
 >  / home / dev2.destoffenstraat.com / app / code / Amasty / CheckoutGiftWrap / Block / Sales / Order /
Filename/home/dev2.destoffenstraat.com/app/code/Amasty/CheckoutGiftWrap/Block/Sales/Order/Fee.php
Size2.17 kb
Permissionrwxrwxrwx
Ownerroot : root
Create time17-Aug-2025 10:26
Last modified23-Nov-2022 12:33
Last accessed23-Aug-2025 08:20
Actionsedit | rename | delete | download (gzip)
Viewtext | code | image
<?php

declare(strict_types=1);

/**
* @author Amasty Team
* @copyright Copyright (c) 2022 Amasty (https://www.amasty.com)
* @package One Step Checkout Gift Wrap for Magento 2 (System)
*/

namespace Amasty\CheckoutGiftWrap\Block\Sales\Order;

use Amasty\CheckoutCore\Model\ResourceModel\Fee\CollectionFactory as FeeCollectionFactory;
use Magento\Framework\View\Element\AbstractBlock;
use Magento\Framework\View\Element\Template\Context;
use Magento\Sales\Api\Data\OrderInterface;

class Fee extends AbstractBlock
{
/**
* @var FeeCollectionFactory
*/
private $feeCollectionFactory;

public function __construct(
Context $context,
FeeCollectionFactory $feeCollectionFactory,
array $data = []
) {
parent::__construct($context, $data);
$this->feeCollectionFactory = $feeCollectionFactory;
}

/**
* Create the Gift Wrap totals summary
*
* @return $this
*/
public function initTotals()
{
$parent = $this->getParentBlock();

if (!$parent || !method_exists($parent, 'getOrder')) {
return $this;
}

/** @var \Magento\Sales\Model\Order $order */
$order = $parent->getOrder();

if (!($order instanceof OrderInterface)) {
return $this;
}

$quoteId = $order->getQuoteId();

$feesQuoteCollection = $this->feeCollectionFactory->create()
->addFieldToFilter('quote_id', $quoteId);

$feeAmount = 0;
$baseFeeAmount = 0;

/** @var \Amasty\CheckoutCore\Model\Fee $fee */
foreach ($feesQuoteCollection->getItems() as $fee) {
$feeAmount += $fee->getData('amount');
$baseFeeAmount += $fee->getData('base_amount');
}

if ($feesQuoteCollection->getSize()) {
$total = new \Magento\Framework\DataObject(
[
'code' => $this->getNameInLayout(),
'label' => __('Gift Wrap'),
'value' => +$feeAmount,
'base_value' => +$baseFeeAmount
]
);

$parent->addTotalBefore($total, 'grand_total');
}

return $this;
}
}