I added custom check box field in checkout 1st step below Shipping Methods section.

enter image description here

how to check is checked or not when i click next button,so based on this I can add custom fee in order totals.

when I click next button its calling rest api ShippingInformationManagement.

i think i need to override saveAddressInformation method in ShippingInformationManagement class.

Please find below for more details.


1 Answer 1


Follow the step:

how to check is checked or not when i click next button,so based on this I can add custom fee in order totals.

--You need to js saveShippingInformation method by following way. Create a requirejs-config.js [Vendor/Module/view/frontend/requirejs-config.js]

var config = {
    "map": {
        "*": {
            'Magento_Checkout/js/model/shipping-save-processor/default': 'vendor_Module/js/model/shipping-save-processor/default'

Now create default.js[Vendor/Module/view/frontend/web/js/model/shipping-save-processor/default.js]

Here you need to pass additional param. Here is an example Check following params

                            delivery_date: $('[name="delivery_date"]').val()

Now you can able to pass value to api.

Create Vendor/Module/etc/di.xml for pluginize ShippingInformationManagement.

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="Magento\Checkout\Model\ShippingInformationManagement">
        <plugin name="sr_save_delivery_date_in_quote" type="Vendor\Module\Plugin\Checkout\Model\ShippingInformationManagement" sortOrder="1"/>

Create Vendor/Module//Plugin/Checkout/Model/ShippingInformationManagement.php

namespace Vendor\Module\Plugin\Checkout\Model;
class ShippingInformationManagement
    protected $quoteRepository;
    public function __construct(
        \Magento\Quote\Model\QuoteRepository $quoteRepository
    ) {
        $this->quoteRepository = $quoteRepository;
     * @param \Magento\Checkout\Model\ShippingInformationManagement $subject
     * @param $cartId
     * @param \Magento\Checkout\Api\Data\ShippingInformationInterface $addressInformation
    public function beforeSaveAddressInformation(
        \Magento\Checkout\Model\ShippingInformationManagement $subject,
        \Magento\Checkout\Api\Data\ShippingInformationInterface $addressInformation
    ) {
        $extAttributes = $addressInformation->getExtensionAttributes();
        $deliveryDate = $extAttributes->getDeliveryDate();

Create Vendor/Module/etc/extension_attributes.xml

<?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="delivery_date" type="string"/>

You can use this module as an example

  • Hy @Sohel I want to add some extra amount to shipping amount for that I've overrided ShippingInformationManagement now when I update the shipping amount that is not updated in DB $quote->setShippingAmount(30) but still when I log the file then I still see the old prices... did you know anything about this?
    – Asad Khan
    Commented Apr 18, 2022 at 12:57

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.