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
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.
Use directly the objectManager is a bad practice ! \Magento\Framework\App\ObjectManager::getInstance(), Read here
app/code/{Vendor}/{ModuleName}/Helper/Data.php
public function getConfig($config_path)
{
return $this->scopeConfig->getValue(
$config_path,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
);
}
$flatratePrice = $this->helper('{Vendor}\{ModuleName}\Helper\Data')->getConfig('carriers/flatrate/price');
$flatrateHandlingFee = $this->helper('{Vendor}{ModuleName}\Helper\Data')->getConfig('carriers/flatrate/handling_type');