How to Use “checkout_type_multishipping_create_orders_single” Event in Magento 2
In a Magento 2 store, the admin may want to configure multiple shipping addresses that allows customers to have their orders delivered to more than one address on the checkout page. Admin may need to add a custom field in multi shipping of the checkout page in Magento 2 store, i.e., Extra Fee.
While adding a custom field, it requires adding its value to the sales_order_table to validate that value. In that case, you need to override the event and observer. Events in Magento 2 are dispatched based on an action performed, and it passes data to the observer. Observers are Magento classes that are executed when an event is dispatched.
In that scenario, you need to use “checkout_type_multishipping_create_orders_single” event in Magento 2.
Method to Use “checkout_type_multishipping_create_orders_single” Event in Magento 2
- Create event.xml file at Vendor\Module\etc
123456<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd"><event name="checkout_type_multishipping_create_orders_single"><observer name="surcharge_to_order_multi" instance="Vendor\Module\Observer\MultiSurchargeOrder"/></event></config> - Create MultiSurchargeOrder.php file at Vendor\Module\Observer
1234567891011121314<?phpnamespace Vendor\Module\Observer;use Magento\Framework\Event\Observer;use Magento\Framework\Event\ObserverInterface;class MultiSurchargeOrder implements ObserverInterface{public function execute(Observer $observer){// here you can add code to save in order tabel at time multi shippinging place order}}
Follow these steps and enhance the customer experience!
Doubts will be entertained in the Comments section below. Also, let me know how have you used this order data for the betterment.
I would be happy to help.
Feel free to share the solution with Magento Community via social media.
Thank You.
Sanjay Jethva
Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe.
His passion for Magento 2 and Shopify solutions has made him a trusted source for businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.
Prev
How to Remove Column from Admin Grid Dynamically in Magento 2
How to Get Order Status Label in Magento 2
Next