Hi everybody, I am Cuong, Welcome back to my Magento 2 tutorial video series.
Today, I am going to show everybody a best practice, How to create a new shipping method in Magento 2.
By default, Magento 2 provides us some shipping methods as Flat Rate, Free Shipping, Table Rates, UPS, USPS, FedEx, DHL, you can see these shipping methods by going to the Stores → Settings → Configuration → Sales → Shipping Methods.
If you don’t want to use these shipping methods, you can create a new custom shipping method via your requirements, this practice will help you to do it working.
Let’s do this practice, you need to follow steps by step:
Step 1: Declaring a new module called PHPCuong_ShippingExpress
– Create the namespace PHPCuong in the path appcode.
– Create the module named ShippingExpress in the path appcodePHPCuong.
– Create the file named registration.php in the path appcodePHPCuongShippingExpress
– Create the file named module.xml in the path appcodePHPCuongShippingExpressetc
End of the step #1, I have been completed the step to create a new module called PHPCuong_ShippingExpress.
Step 2: Declaring a new shipping method
– Create the new file system.xml in the path appcodePHPCuongShippingExpressetcadminhtml
– Create the new file config.xml in the path appcodePHPCuongShippingExpressetc
This file helps us to set the default value for the new shipping method.
– Create the new file Express.php in the path appcodePHPCuongShippingExpressModelCarrier
Step 3: Test and See the results
Run the commands line following:
php bin/magento setup:upgrade –keep-generated
php bin/magento cache:flush
Go to the backend Stores → Settings → Configuration → Sales → Shipping Methods.
the new shipping method has been created successfully.
Enable this shipping method and test it on the storefront.
Go to the storefront, add a product to the shopping cart and go to the checkout page.
Yeah, it works perfectly.
For now, I try to change the price.
Thank you for your watching. If you have any questions about this practice please feel free to leave a comment below.
Don’t forget to like, comment, share and subscribe to my channel for getting the latest videos.
Please do not hesitate to contact me if you need me to join your Magento project. My rate is $25/hour in Magento 1 and $30/hour in Magento 2.
Xem thêm Bài Viết:
- VẼ SHOPDRAWING CẤP THOÁT NƯỚC CHO NHÀ Ở|Kỹ Thuật Thi Công Cơ Điện MECHANICAL ENGINEERING
- PUBG Mobile | Khám Phá Acc Siêu Khủng Của Mixigaming | Karos TV
- Giới thiệu khóa học – Revit shop drawing – Hệ thống điện
- VẼ SHOP-DRAWING ĐỒ NỘI THẤT, VẼ BÓC TÁCH CHI TIẾT TỦ KỆ -1
- Đi Chợ Lạc Xoong, Ve Chai, Đồ Cũ Nhật Tảo Mua Đồng Hồ Lắc Kê Vàng Giá 200 Ngàn