I successfully pass the extension attribute value to estimate-shipping-method,like this:

enter image description here


<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Api/etc/extension_attributes.xsd">
    <extension_attributes for="Magento\Checkout\Api\Data\ShippingInformationInterface">
        <attribute code="shipping_delivery_date" type="string"/>
    <extension_attributes for="Magento\Quote\Api\Data\AddressInterface">
        <attribute code="shipping_delivery_date" type="string" />

I want to retrieve it in my custom carrier model, but no luck

class MyCarrier extends \Magento\Shipping\Model\Carrier\AbstractCarrier implements
    public function collectRates(RateRequest $request)
       $deliveryDate = $request->getExtensionAttributes()->getShippingDeliveryDate();

1 Answer 1


Well, you are basically setting the extension attributes on the shipping address object and inside the carrier model you are handling the rate request object - as you can tell, two different objects.

If you check the rate request class vendor/magento/module-quote/Model/Quote/Address/RateRequest.php you will see that you don't have a direct way to retrieve data from the shipping address object.

But if you look at vendor/magento/module-offline-shipping/Model/Carrier/Tablerate.php you will see that at some point there's something like this:

// ...
foreach ($request->getAllItems() as $item) {
    // ...
                   $freeShipping = $item->getFreeShipping() ?
                        $item->getFreeShipping() : $item->getAddress()->getFreeShipping();
    // ...
// ...

so, I'm thinking that the $item->getAddress() thing might lead back to the shipping address object and after that you could check if you can extract the extension attributes from it. I didn't test this, but it's worth a try.

Good luck!

  • It works and I understood why. Because any products can have separated shipping details. Multishipping... It is why Magento will create separated shipping address for each product in the cart...
    – Arni
    Apr 30, 2023 at 12:00

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.