I'm making new shipping method and I need to add new column to checkout shipping rates. Data would come from custom shipping method settings, for example method description. Or some input field where customer can add info (data probably would be saved in quote and later in order).

Probably the easiest part of all is implement template by using


It just needs this

<div data-bind="text: method.description"></div>

Problem is I can't figure out how to add custom data. It's not enough to add this:

public function collectRates(RateRequest $request)
    if (!$this->isActive()) return false;

    $method = $this->rateMethodFactory->create();
    $method->setData('carrier', $this->getCarrierCode());
    $method->setData('carrier_title', $this->getConfigData('title'));
    $method->setData('method_title', $this->getConfigData('title'));
    $method->setData('method', $this->getCarrierCode());
    $method->setData('cost', $this->_price);

    // custom
    $method->setData('description', $this->getConfigData('description'));

    $result = $this->rateResultFactory->create();

    return $result;

Data for html comes from js rates(), which gets data from API:

<route url="/V1/carts/:cartId/shipping-methods" method="GET">
    <service class="Magento\Quote\Api\ShippingMethodManagementInterface" method="getList"/>
        <resource ref="Magento_Cart::manage" />

After this there are many steps while something actually gets collected. I found

Magento\Quote\Model\Cart\ShippingMethodConverter modelToDataObject()

that looked the most promising but if I try to add my attribute to it, nothing happens.

So my question is, if there actually is a way to add new data to shipping rates? In M1 it was possible. It would be crazy if M2 it wasn't possible.

There are many reasons why this should be possible. For example if I wanted to make pick up in store method with multiple stores drop down or something similar.

  • Hi , If you got the solution could you please share? – konika Feb 13 '17 at 9:01
  • Well, any solution to this? – Piyush Dangre Apr 25 '17 at 4:53
  • I'm waiting this answer. – Diego Queiroz May 8 '18 at 10:44

You need to declare the method names in interface file, the path for this file is


Declare constant at the top

const KEY_DESCRIPTION = 'description';  

then define method as follows

public function getDescription();
public function setDescription($desc);

Then you need to assign values to the following file


as follows

public function getDescription()
  return $this->_get(self::KEY_DESCRIPTION);
public function setDescription($desc)
  return $this->setData(self::KEY_DESCRIPTION, $desc);
  • Adding method to public api (vendor/magento/module-quote/Api/Data/ShippingMethodInterface.php )??? Never do that. – Pete Jaworski Apr 16 '18 at 18:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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