Add Steps Before and After Shipping and Payment Review

Customizing checkout page has always been trend to gain more sales. More you ease your customer, more you gain sales on your store. From day to day, the checkout process is improving and merchants are demanding simpler but most effective checkout process. The checkout steps are important part of gaining customer attention to your store. …

Magento2 – How to load Quote by Quote id

By Using Object Manager you can inject the instace of \Magento\Quote\Model\QuoteFactory The other and recommended way, you can load the quote id by injecting the instance of \Magento\Quote\Model\QuoteFactory To use it you can write: $q = $this->quoteFactory->create()->load($quoteId);

Magento2 – How to get Store Name

To get store name you need instance of \Magento\Framework\App\Config\ScopeConfigInterface You can get the instance by objectManager. Use the following code get the Store Name: $scope = \Magento\Framework\App\ObjectManager::getInstance()->get(‘\Magento\Framework\App\Config\ScopeConfigInterface’); echo $scope->getValue( ‘general/store_information/name’, \Magento\Store\Model\ScopeInterface::SCOPE_STORE ); If store name configuration is defined there then it will be printed otherwise the output will be blank.

Magento2 – How to get Current Url

To get url of the current page, the code below works everywhere: $objectManagerInstance = \Magento\Framework\App\ObjectManager::getInstance(); $url = objectManagerInstance -> get(‘Magento\Framework\UrlInterface’); echo $url -> getCurrentUrl(); From a .phtml template you can also do it shorter by calling the \Magento\Framework\View\Element\AbstractBlock::getUrl(); Without using objectManager you can use inside your class here Initialize your object : private $_urlInterface Now …

Magento2 – How to get Directory of a Module

Here is the code how to load your module directory: $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $directoryReader = $objectManager->create(‘\Magento\Framework\Module\Dir\Reader’); $moduleDirectory = $directoryReader->getModuleDir(”, ‘Knowthemage_Hello’); echo “Directory : “.$moduleDirectory;

Magento2 – How to Get Country Name Using Country Code

Create Instance to Object Manager then inject dependency to perform your query: $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); Now load your country by the following code: $country = $objectManager->create(‘\Magento\Directory\Model\Country’)->load(‘AE’)->getName(); While AE is the country code. The output of above code will be: United Arab Emirates

Magento2 How to Get Country Code Collection

Fortunately magento2 introduces many ways to get data from collection. Here we are following from those of two approaches : 1. Get the country code collection by getting the instance of object manager class and get the method by passing class dependency to ‘get’ method of objectManager class instance: $o = \Magento\Framework\App\ObjectManager::getInstance(); $_countryCollectionFactory = $o->get(‘\Magento\Directory\Model\ResourceModel\Country\CollectionFactory’); …

Magento Load Product By Id

To load product by id, use the load($id) function by providing product id as parameter following the Product Model Class Mage_Catalog_Product_Model. A single product with object array will be loaded. To retrieve data simply use   For Instance The output of above code will be : View Demo Product