• Magento 2

    Magento2 How to disabled free shipping method at frontend

    Magento2 How to disabled free shipping method at frontend. In this article, I am going to show Magento2 How to disabled free shipping method at frontend. At magento2, it difficult to disable a shipping method at frontend and Enable at admin area. At first, I target to override  Free shipping method class  Magento\OfflineShipping\Model\Carrier\Freeshipping ‘s method  collectRates() using Plugin around method <?php namespace Devamitbera\CoreRewrite\Plugin; /** * Disabled Freeshipping for frontend */ class DisabledFreeShippingForFrontPlugin { protected $appState; public function __construct( \Magento\Framework\App\State $appState ) { $this->appState = $appState; } public function aroundCollectRates( \Magento\OfflineShipping\Model\Carrier\Freeshipping $subject , \Closure $proceed , \Magento\Quote\Model\Quote\Address\RateRequest $request ) { /* If ares is frontend then return false for disable shipping method at frontend */…

  • magento2 base url
    Magento 2

    How to get magento2 base url

    How to get magento2 base url. You want to get magento2 base url for your current store then you can follow this post. During your daily work, several time, you need to current store base url  and at Magento 1.x version you can get base url using Mage::getBaseUrl();As Magento2, do not used factory patterns, so the code like  Mage::getBaseUrl();  is not exist by which you can base URL.But at Magento2, you should use StoreManager object  and  using  $this->_storeManager->getStore()->getBaseUrl()  you can get base url. Magento2, use interface, injection of class, that you should  Inject. Magento\Store\Model\StoreManagerInterface at Model, Resource model, Block, Helper classes for getting base url using below code: $objectManager = \Magento\Framework\App\ObjectManager::getInstance();…