I am working on custom extension and need to execute my code when the customer clicks on "Next" button available in checkout.

I need an event observer in which, used shipping and billing address selected or added by customer.

See screenshot.

enter image description here

  • what about sales_quote_collect_totals_after ? – Keyur Shah Nov 9 '16 at 13:09
  • @KeyurShah already try that event, but not working. – Dhiren Vasoya Nov 9 '16 at 13:10
  • What do you mean by not working ? this event always execute – Keyur Shah Nov 9 '16 at 13:12
  • @KeyurShah can give me sample code using which, I get selected address into of customer. I need event only for this action not every time cart is reload or other function. – Dhiren Vasoya Nov 9 '16 at 13:19

You should use plugin to get the shipping info:

Your di should be under etc folder: app/code/Extension/Vendor/etc/di.xml

<?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="get_shipping_info" type="Vendor\Module\Plugin\Checkout\Model\ShippingInformationManagement" sortOrder="1"/>

Your Plugin:

     * @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

    public function afterSaveAddressInformation(
        \Magento\Checkout\Model\ShippingInformationManagement $shipping,
| improve this answer | |
  • I will check and let you know. – Dhiren Vasoya Nov 9 '16 at 13:19
  • I am try above code, but in not called our function when we click on "Next" button. – Dhiren Vasoya Nov 10 '16 at 4:52
  • Which is your function? the saveAddressInformation() function will be called when click Next. – Khoa TruongDinh Nov 10 '16 at 4:58
  • I try to implement this public function afterSaveAddressInformation but not called – Dhiren Vasoya Nov 10 '16 at 5:06
  • Updated my answer. – Khoa TruongDinh Nov 10 '16 at 5:31

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.