Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am working on custom extension and need execute my code when custom click on "Next" button available in checkout.

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

See screenshot.

enter image description here

share|improve this question
    
what about sales_quote_collect_totals_after ? – Keyur Shah Nov 9 at 13:09
    
@KeyurShah already try that event, but not working. – Dhiren Vasoya Nov 9 at 13:10
    
What do you mean by not working ? this event always execute – Keyur Shah Nov 9 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 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"/>
    </type>
</config>

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,
        $cartId,
        \Magento\Checkout\Api\Data\ShippingInformationInterface $addressInformation
    )
    {
       ......
    }

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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