1

How can I retrieve the cost of fixed delivery (Handling Fee) that is set in administration, in one of my phtml files, so I can show the value of it?

Thank you

Bawsi
  • 193
  • 1
  • 10

2 Answers2

1

You can get flat rate price by using below code in phtml:

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$flatratePrice = $objectManager->get('Magento\Framework\App\Config\ScopeConfigInterface')->getValue('carriers/flatrate/price');

You can inject the scopeconfiginterface to block and then use directly in your phtml if needed.

Sukumar Gorai
  • 10,823
  • 4
  • 19
  • 46
0

Use directly the objectManager is a bad practice ! \Magento\Framework\App\ObjectManager::getInstance(), Read here

  1. app/code/{Vendor}/{ModuleName}/Helper/Data.php

    public function getConfig($config_path)
    {
        return $this->scopeConfig->getValue(
                   $config_path,
                   \Magento\Store\Model\ScopeInterface::SCOPE_STORE
               );
    }
    
  2. $flatratePrice = $this->helper('{Vendor}\{ModuleName}\Helper\Data')->getConfig('carriers/flatrate/price');
    

    $flatrateHandlingFee = $this->helper('{Vendor}{ModuleName}\Helper\Data')->getConfig('carriers/flatrate/handling_type');

PЯINCƎ
  • 11,669
  • 3
  • 25
  • 80