Creating a Shipping Module for Magento 2

Feb 21, 2017481
Creating a Shipping Module for Magento 2

In this new article I’m going to show you how to create a custom shipping module for Magento 2 platform. Here below you can see the structure of the module:

Creating a Shipping Module for Magento 2

1. At first let’s register our module in the system. In order to get that done we should create the following files:

app/code/BelVG/NewShipping/etc/module.xml

and app/code/BelVG/NewShipping/registration.php

2. We should provide an ability for users to configure the new shipping method. That’s why we must create new fields in admin panel (Stores->Configuration->Sales->Shipping Methods). And that is what will help us:

app/code/BelVG/NewShipping/etc/adminhtml/system.php

3. Here we create configuration file of our new module:

app/code/BelVG/NewShipping/etc/config.php

Partner With Us Let's discuss how to grow your business. Get a Free Quote.
Talk to Vlad

4. The next step is creating a model of shipping method, where we can describe the logical circuitry of app/code/BelVG/NewShipping/Model/Carrier/Shipping.php. And here it is necessary to implement these two methods: collectRates and getAllowedMethods.

Whereafter we should enable the module by running the following commands:

php bin/magento module:enable -c BelVG_NewShipping

php bin/magento setup:upgrade

And here in admin panel we are able to configure the shipping method:

Stores-> Configuration-> Sales-> Shipping Methods

Creating a Shipping Module for Magento 2

And what concerns the frontend, during the order placement process a user can simply select our new shipping method.

Creating a Shipping Module for Magento 2

Creating a Shipping Module for Magento 2


Partner With Us Looking for a partner that will help you to grow your business? We are the right company to develop your webstore. Feel free to get in touch with us. We will be happy to discuss your business opportunities and provide you with a Free Quote. Talk to Vlad

Post a new comment

top
BelVG Newsletter
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.
Email *