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/vendor/magento/module-tax/Observer/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/vendor/magento/module-tax/Observer/UpdateProductOptionsObserver.php
<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

namespace Magento\Tax\Observer;

use Magento\Framework\Event\ObserverInterface;

class UpdateProductOptionsObserver implements ObserverInterface
{
    /**
     * Tax data
     *
     * @var \Magento\Tax\Helper\Data
     */
    protected $taxData;

    /**
     * @var \Magento\Framework\Registry
     */
    protected $registry;

    /**
     * @param \Magento\Tax\Helper\Data $taxData
     * @param \Magento\Framework\Registry $registry
     */
    public function __construct(
        \Magento\Tax\Helper\Data $taxData,
        \Magento\Framework\Registry $registry
    ) {
        $this->taxData = $taxData;
        $this->registry = $registry;
    }

    /**
     * Change default JavaScript templates for options rendering
     *
     * @param \Magento\Framework\Event\Observer $observer
     * @return $this
     */
    public function execute(\Magento\Framework\Event\Observer $observer)
    {
        $response = $observer->getEvent()->getResponseObject();
        $options = $response->getAdditionalOptions();

        $_product = $this->registry->registry('current_product');
        if (!$_product) {
            return $this;
        }

        $algorithm = $this->taxData->getCalculationAlgorithm();
        $options['calculationAlgorithm'] = $algorithm;
        // prepare correct template for options render
        if ($this->taxData->displayBothPrices()) {
            $options['optionTemplate'] = sprintf(
                '<%%= data.label %%>'
                . '<%% if (data.finalPrice.value) { %%>'
                . ' +<%%= data.finalPrice.formatted %%> (%1$s <%%= data.basePrice.formatted %%>)'
                . '<%% } %%>',
                __('Excl. tax:')
            );
        } elseif ($this->taxData->priceIncludesTax() && $this->taxData->displayPriceExcludingTax()) {
            $options['optionTemplate'] = sprintf(
                '<%%= data.label %%>'
                . '<%% if (data.basePrice.value) { %%>'
                . ' +<%%= data.basePrice.formatted %%>'
                . '<%% } %%>'
            );
        }

        $response->setAdditionalOptions($options);
        return $this;
    }
}

Spamworldpro Mini