Custom Shipping Text Filed: Show Custom Text Magento 2

Here, In this article, I am going to explain how we can add a custom shipping text field in Magento 2 admin shipping method section.

Wishusucess ShippingTexarea Magento 2 extension will add a custom text field in Flat Rate shipping method, Table Rate shipping method, and Free Shipping method.

 

Custom Shipping TextArea Module Basic File

In order to get these features in Magento 2 admin shipping method, we need only 3 files to create then we can easily achieve this functionality. files are given in below.

app/code/Wishusucess/ShippingTexarea/registration.php

app/code/Wishusucess/ShippingTexarea/etc/module.xml

app/code/Wishusucess/ShippingTexarea/adminhtml/system.xml

 

 

Register Custom Shipping Text Module

As we know this is one of the most basic files for any kind of Magento 2 module. So we have created a registration.php file to get registered with our custom shipping text method module.

app/code/Wishusucess/ShippingTexarea/registration.php

<?php
/*
* @Author Hemant Singh
* @Developer Hemant Singh
* @Module Wishusucess_ShippingTextarea
* @copyright Copyright (c) Wishusucess (http://www.wishusucess.com/)
*/
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Wishusucess_ShippingTexarea',
__DIR__
);

 

Give Custom Shipping Module Name

Here you have to give the module basic information through the XML file. It's a configuration file for the custom shipping text module.

app/code/Wishusucess/ShippingTexarea/etc/module.xml directory module. This file is a basic file that always needs to create a module across all Magento 2 configuration files.

app/code/Wishusucess/ShippingTexarea/etc/module.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Wishusucess_ShippingTexarea" setup_version="1.0.1">
</module>
</config>

 

Create Custom Shipping Text Field Through XML File

Now we have to create a system.xml file This configuration file is used to create configuration fields in Magento 2 System Configuration.

This file gives options to add a custom field on Magento 2 admin side. Here we can define different types of entities.

The most important thing which we need to remember about this file is the relationship between tabs, sections, groups, and fields.

app/code/Wishusucess/ShippingTexarea/adminhtml/system.xml

<?xml version="1.0"?>
<!--
/*
* @Author Hemant Singh
* @Developer Hemant Singh
* @Module Wishusucess_ShippingTextarea
* @copyright Copyright (c) Wishusucess (http://www.wishusucess.com/)
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
<section id="carriers" type="text" sortOrder="320" showInDefault="1" showInWebsite="1" showInStore="1">
<group id="flatrate" translate="label" type="textarea" sortOrder="0" showInDefault="1" showInWebsite="1" showInStore="1">
<field id="customtext" translate="label" type="textarea" sortOrder="9" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Displayed Custom Message</label>
</field>
</group>
<group id="tablerate" translate="label" type="textarea" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<field id="customtext" translate="label" type="textarea" sortOrder="101" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Displayed Custom Message</label>
</field>
</group>
<group id="freeshipping" translate="label" type="textarea" sortOrder="5" showInDefault="1" showInWebsite="1" showInStore="1">
<field id="customtext" translate="label" type="textarea" sortOrder="80" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Displayed Custom Message</label>
</field>
</group>
</section>
</system>
</config>

 

Now, Run Following Command:

php bin/magento setup:upgrade

php bin/magento setup:di:compile

php bin/magento setup:static-content:deplpy -f

php bin/magento cache:clean

 

Now check the result in Magento 2

Admin > Stores > Configuration > Sales > Shipping Method

Custom Shipping Text Field

 

Added Custom Shipping Text Area in Free Shipping Section

Magento 2 Custom Shipping Field

 

Download Link:

Wishusucess Custom Shipping Text Area Extension in Magento 2

 

Hire Magento 2 Expert Developer to Develop Your Store

 

Related Post:

Price Slider: Create Ajax Price Slider Filter in Magento 2

Search AutoComplete: Magento 2 Module Add All Category for Search

Sort By Price: Add Sort By Price High to Low & Low To High in Magento 2

 

Recommended Post:

Magento 2.4 Installation Guide: How to Install Magento 2.4.2

Magento Store: Best 36 Magento Websites Example in The World

SEO Packages: How Much Do SEO Packages Cost in India, SEO Pricing