Create the skeleton of a custom checkout module

Setting Up the Module

It’s finally time for us to start writing some code. Before we do that, we need a place to contain all of our custom code. Let’s create a new Magento module at Macademy/CustomCheckout. First, create a registration.php file. This will be a standard registration.php file that defines our module with the VendorName_ModuleName format.

Next, we will create our etc/module.xml file. This will be a pretty standard module definition file, but instead of self-closing the “module” tag, let’s open it and create a “sequence” node. Add a module node underneath that relating to Magento_Checkout. This creates a dependency on the Magento Checkout module, which will make sure that that module loads first, and our module loads last. Defining this module here is super important! When not defining it initially, you might run into a ton of headaches because things are loaded out of order. So be sure to define this dependency up front. As our code grows and starts depending on other modules, we will continue adding module nodes to this “sequence” node.

Creating Your Own Custom Module

All of the code in this course will go in this Macademy_CustomCheckout module. However, you can also create your own custom module. It’s actually strongly recommended that you do this so you can experiment and play along with your own custom code outside of the code within this course. You can always reference the code created within this CustomCheckout module.

For example, if your name is Mark Shust, you can create a module at MarkShust/MyCheckout. Then, create your registration.php file as usual. You can also create an etc/module.xml file that defines your module and depends on the Magento_Checkout module, just like the module we are building in this course. We will not make any other references to your custom module, but just know that this is a great place to experiment with your own custom code while still following along with the core course material.

Enabling and Registering the Module

Finally, we will need to enable our module with bin/magento module:enable Macademy_CustomCheckout. Then, register our module with bin/magento setup:upgrade. Be sure to repeat this process for your custom module if you’re going down that path.

That’s it! Our module skeleton is enabled, and now we can start writing some custom checkout code.

Complete and Continue  
Extra lesson content locked
Enroll to access all lessons, source code & comments.
Enroll now to Unlock