In magento configuration, I have set Flat Rate like this:

enter image description here

Yet in order confirmation email, {{var order.getShippingDescription()}} returns Flat Rate - Delivery

I'd like to remove Flat Rate, and have just Delivery displayed.

How can I do that?

1 Answer 1


Flat Rate - Delivery is coming from the database column shipping_description of sales_order table.

If you want to changes Flat Rate - Delivery text only for order confirmation mail then best of idea add a new parameter to order confirmation email using event email_order_set_template_vars_before and on this parameter will have to do a string replace on shipping_description field And then order on email template access the new parameter.

See https://magento.stackexchange.com/a/163950/4564

First,Read the dev docs article on Events and observers

1 .Create events.xml at your module means app/code/{VendorName}/{Modulename}/etc

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    <event name="email_order_set_template_vars_before">
        <observer name="changes_shippig_descitption_text" 
            instance="{VendorName}\{Modulename}\Observer\ChangesShippingText" />

2 .Add new parameter named new_shippping_desc to email using transportObject

namespace {VendorName}\{Modulename}\Observer;

use Magento\Framework\Event\ObserverInterface;

class ChangesShippingText implements ObserverInterface

  public function execute(\Magento\Framework\Event\Observer $observer)
     $transport = $observer->getTransportObject();
     $order = $transport->getData('order');
     $shippingDes = $order->getShippingDescription();
     $trimDescription = str_replace("Flat Rate -","",$shippingDes);
  1. After on order_email template changes the code {{var order.getShippingDescription()}} to `{{var new_shippping_desc}}
  • I don't understand the details of this, please post the code as a answer
    – zekia
    Commented May 22, 2020 at 7:38
  • Code is attach on the post
    – Amit Bera
    Commented May 22, 2020 at 7:55
  • observer file should be called ChangesShippingText.php and should be placed in directory app/code/{VendorName}/{Modulename}/Observer?
    – zekia
    Commented May 22, 2020 at 8:33
  • yes, right.app/code/{VendorName}/{Modulename}/Observer
    – Amit Bera
    Commented May 22, 2020 at 9:27
  • have you tested your solution? It currently breaks email sending. Please confirm that app/code/{VendorName}/{Modulename}/Observer/ChangesShippingText.php is correct
    – zekia
    Commented May 22, 2020 at 13:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.