Shipping Methods Implementation in Magento 2

- Magento 2

Magento 2 Shipping Methods Implementation

Below, we discuss such an important topic as the Magento 2 shipping methods implementation. The article includes useful Magento 2 tutorials and the description of sample third party extensions as well as core Magento 2 modules. If you are going to master the implementation of shipping methods in Magento 2, the following post can help you achieve your goal.

Since Magento 2 organizes its modules not like you’ve used to see in 1.X, it is necessary to figure out some differences. First of all, you should understand that code pools are a thing of the past. Then, pay attention to a place, where you organize your code. Now, it is a vendor directory and a subdirectory for the module (in our case it is Shipping). Please note that all your code is situated in the /app/code directory.

To implement a shipping method in Magento 2, you will have to create an “etc” subdirectory, which will contain your module XML documents. This step is vital, since the new subdirectory will help to describe your module to Magento 2.

As we all know, module configuration in 1.X are contained in a single XML file which is impossible to read and manage. Luckily, in case of Magento 2 we get a number of different XML documents. Hence, it is much easier to find relevant information on shipping methods in Magento 2. The whole procedure of the Magento 2 shipping module development is described here: Creating a Magento 2 Shipping Module.

Magento 2 Shipping Methods

Magento 2 Shipping Methods: Sample Modules

You will find some sample shipping modules for Magento 2 in the following section of the article. The extensions will be extremely useful if you are trying to master the implementation of shipping methods in Magento 2.

Sample Module Shipping Provider

This sample module demonstrates Magento 2 features related to shipping. The extension adds a shipping carrier, an “In-Store Pickup” shipping carrier, and several pickup locations. CarrierInterface is implemented due to a carrier class which represents a shipping carrier. Please note that every shipping carrier require at least one shipping method, which should have carrier code and title, method code and title, as well as price. The module is configurable via the admin panel. For further information follow the link below.

Magento 2 shipping methods

Download Sample Module Shipping Provider

Magento 2 Custom Shipping Method

This Magento 2 extension was designed to help with creating custom shipping methods. To get it up and running on your Magento 2 project, you only have to copy the SR folder to app/code/, run the following command:

and clear Magento 2 cache.

Custom Shipping Method in Magento 2

Download Magento 2 Custom Shipping Method

Magento2 Custom Shipping

The name of this module is quite eloquent. It has the same purpose as the aforementioned solution. Magento2 Custom Shipping is a sample module, so you should use it for educational purposes only.

Magento 2 Custom Shipping methods

Download Magento2 Custom Shipping

Core Examples of Payment Methods Implementation in Magento 2

  • Magento_Shipping. This module provides interfaces abstract models for integration with every shipping carrier. Besides, it includes the Shipment entity web interface. Please note that it is necessary to extend the abstractions every time you add new shipping carrier.
  • Magento_OfflineShipping. Due to this module, you can implement those shipping methods which do not require a direct interaction with shipping carriers. Such methods are called offline shipping methods, and they include Free Shipping, Flat Rate, Table Rates, and Store Pickup.
  • Magento_Multishipping. As for Magento_Multishipping, this module allows customer to request shipping to several address via different carriers. Thus, you get alternative to standard checkout flow.

As you can see, the implementation of shipping methods in Magento 2 differs from the algorithm you used to work with in 1.X: it is more convenient and at the same time provide wider opportunities. If you have any questions, feel free to ask us in comments, because we are here to help you!