2

I am creating a module in magento2. Currently my planning is when user will provide the shipping address detail and will click the next button, in back-end I will get the address given by the user , according to that I will send a api request to the shipping api, so that when user views the Reviews and payment section, I can show him/her when the product will be delivered.

But as per above plan, I am stuck at how to handle the next button click and getting the address input.

Please give some hints. So that I can proceed.

I have gone through the discussion in M2: Sending data by clicking Next on checkout. But Not getting any information.

Also searched in google. But no result.

Please help.

enter image description here

2

If you want to implement custom shipping module, you don't need any additional handlers to get a shipping address. In this case, you need to implement shipping provider like in the sample module.

If you want to implement some module, which uses shipping address for own purposes you need to used plugins.

In your case it should be plugin for the \Magento\Checkout\Api\GuestShippingInformationManagementInterface::saveAddressInformation and it should be configured to call before main method execution. Something like this:

<config>
    <type name="Magento\Checkout\Api\GuestShippingInformationManagementInterface">
        <plugin name="some_name_of_plugin" type="PluginClassName" />
    </type>
</config>

And it the plugin class you need to implement the before method:

class Plugin{

    public function beforeSaveAddressInformation(GuestShippingInformationManagementInterface $management, $cartId, ShippingInformationInterface $addressInformation)
    {
       //do something here
    }
}

For more additional information, please, see dev docs plugins section.

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.