Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/old/app/code/Cnc/Checkout/Block/Total/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/app/code/Cnc/Checkout/Block/Total/SavedMoney.php
<?php
/**
 * Copyright (c) 2020 Kaliop Digital Commerce (https://digitalcommerce.kaliop.com) All Rights Reserved.
 * https://opensource.org/licenses/OSL-3.0  Open Software License (OSL 3.0)
 * Cnc
 * Radosław Stępień <[email protected]> <[email protected]>
 */
namespace Cnc\Checkout\Block\Total;

use Magento\Checkout\Block\Cart\AbstractCart;
use Magento\Checkout\Model\Session as CheckoutSession;
use Magento\Customer\Model\Session;
use Magento\Framework\Pricing\PriceCurrencyInterface;
use Magento\Framework\View\Element\Template\Context;

class SavedMoney extends AbstractCart
{
    /**
     * @var PriceCurrencyInterface
     */
    private $priceCurrency;

    /**
     * SavedMoney constructor.
     * @param Context $context
     * @param Session $customerSession
     * @param CheckoutSession $checkoutSession
     * @param PriceCurrencyInterface $priceCurrency
     * @param array $data
     */
    public function __construct(
        Context $context,
        Session $customerSession,
        CheckoutSession $checkoutSession,
        PriceCurrencyInterface $priceCurrency,
        array $data = []
    ) {
        parent::__construct($context, $customerSession, $checkoutSession, $data);
        $this->priceCurrency = $priceCurrency;
    }

    /**
     * @return float|int
     */
    public function getSavedMoney()
    {
        $savedAmount = 0;
        $cartItems = $this->getQuote()->getItems();
        foreach ($cartItems as $item) {
            if ($manufacturerPrice = $item->getProduct()->getCncManufacturerPrice()) {
                $savedAmount = $savedAmount + (($manufacturerPrice - $item->getPrice()) * $item->getQty());
            }
        }
        return $this->priceCurrency->format($savedAmount, false);
    }
}

Spamworldpro Mini