Hello Magento Friends,

In today’s blog, I will explain How to Add Additional Text based on Selected Shipping Methods in the Checkout in Magento 2.

Sometimes you need to add a custom shipping method to your Magento 2 store. When a customer selects the shipping method at the checkout page, it looks as below.

Shipping method

You might prefer to show additional text for the custom shipping method. When a customer selects a particular shipping method, you can show additional text at the checkout page in Magento 2 using the following method.

Steps to Add Additional Text Based on Selected Shipping Methods in the Checkout in Magento 2:

Step 1: Create a Template file in the path given below.  

{{magento_root}}\app\code\Vendor\Extension\view\frontend\web\template\shipping-info.html

And add the code as follows.

Step 2: Create a Layout file in the following path.

{{magento_root}}\app\code\Vendor\Extension\view\frontend\layout\checkout_index_index.xml

Then add the code as given below.

Step 3: Create a Javascript file at the below-mentioned file

{{magento_root}}\app\code\Vendor\Extension\view\frontend\web\js\view\shipping-info.js

Now add the following code snippet

Step 4: After that, run the below commands in terminal

After implementing the above steps, you can see that the custom text is displayed based on the selected shipping method at the checkout page in Magento 2.

shipping method with custom text

Conclusion:

Hopefully, you will be able to show additional text based on selected shipping methods at the checkout of your Magento 2 store. Share the tutorial with your friends, and be in touch with us for more Magento solutions.

Happy Coding!

Click to rate this post!
[Total: 1 Average: 5]