---
title: "Magento 2: How to Save Custom Field Value to quote_address for Multi-Shipping Orders"
url: "https://magecomp.com/blog/magento-2-save-custom-field-value-to-quote-address-for-multi-shipping-orders/"
date: "2024-11-08T18:38:28+00:00"
modified: "2025-02-12T09:29:44+00:00"
author:
  name: "Dhiren Vasoya"
  url: "https://magecomp.com/"
categories:
  - "How To"
  - "Magento 2"
word_count: 407
reading_time: "3 min read"
summary: "Hello Magento Friends,"
description: "Learn how to save custom field values to quote_address in Magento 2 for multi-shipping orders. "
keywords: "How To, Magento 2"
language: "en"
schema_type: "Article"
related_posts:
  - title: "How to Get All Active Catalog Rules Collection using Root Script in Magento 2?"
    url: "https://magecomp.com/blog/get-all-active-catalog-rules-collection-using-root-script-magento-2/"
  - title: "How to Get Tracking Information From Shipment in Magento 2"
    url: "https://magecomp.com/blog/get-tracking-information-shipment-magento-2/"
  - title: "Top 10 Magento 2 Development Companies in USA"
    url: "https://magecomp.com/blog/magento-2-development-companies-usa/"
---

# Magento 2: How to Save Custom Field Value to quote_address for Multi-Shipping Orders

_Published: November 8, 2024_  
_Author: Dhiren Vasoya_  

![Magento 2 How to Save Custom Field Value to quote_address for Multi-Shipping Orders copy](https://magecomp.com/blog/wp-content/uploads/2024/11/Magento-2-How-to-Save-Custom-Field-Value-to-quote_address-for-Multi-Shipping-Orders-copy-1024x512.webp)

**Hello Magento Friends,**

In Magento 2, the checkout process allows customers to choose multiple shipping addresses for an order, which is a feature known as “multi-shipping.” When using this feature, it’s important to manage and store additional custom data for each shipping address in a structured way. A common requirement is saving a custom field value on the quote_address model for each shipping address during a multi-shipping order process.
[![Hire Magento Programmer](https://magecomp.com/blog/wp-content/uploads/2025/02/Hire-Magento-Programmer-CTA-3.webp)](https://magecomp.com/services/hire-magento-programmer/)

## Steps to Save Custom Field Value to quote_address for Multi-Shipping Orders in Magento 2:
**Step 1:** First, we need to create a **“events.xml“** file inside our extension at the following path
**app\code\Vendor\Extension\etc\events.xml**

Then add the code as follows
```
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="checkout_controller_multishipping_shipping_post">
        <observer name="custom_multishipping_observer" instance="VendorExtensionObserverSaveCustomFieldToQuoteAddress" />
    </event>
</config>
```

[![Magento version upgrade](https://magecomp.com/blog/wp-content/uploads/2025/02/Magento-2-Version-Upgrade-CTA-2.webp)](https://magecomp.com/services/magento-upgrade-services/)

**Step 2:** After that, we need to create an **“SaveCustomFieldToQuoteAddress.php”** file inside our extension at the following path
**app\code\Vendor\Extension\Observer\SaveCustomFieldToQuoteAddress.php**

And add the code as given below
```
<?php

namespace VendorExtensionObserver;

use MagentoFrameworkEventObserver;
use MagentoFrameworkEventObserverInterface;
use MagentoQuoteApiCartRepositoryInterface;

class SaveCustomFieldToQuoteAddress implements ObserverInterface
{
    protected $quoteRepository;

    public function __construct(
	CartRepositoryInterface $quoteRepository
    ) {
	$this->quoteRepository = $quoteRepository;
    }

    public function execute(Observer $observer)
    {
	$request = $observer->getEvent()->getRequest();
	$quote = $observer->getEvent()->getQuote();

	// Assuming your custom field is 'custom_field' and is sent via POST
	$customFieldValue = $request->getPostValue('customfield');

	// Check if value exists
	if (is_array($customFieldValue) && !empty($customFieldValue)) {
	    // Iterate through each shipping address and assign the correct value
	    foreach ($quote->getAllShippingAddresses() as $address) {
	        $addressId = $address->getId();

	        // Check if a custom field value exists for this address ID
	        if (isset($customFieldValue[$addressId])) {
	            $address->setData('customfield', $customFieldValue[$addressId]);
	        }
	    }
	}
    // Save the quote to persist the data
    $this->quoteRepository->save($quote);
    }
}
?>
```

## Conclusion:
By following these steps, you can easily save and manage custom field values for multi-shipping orders in Magento 2. This is useful for scenarios where you need to capture additional data specific to each shipping address, such as special delivery instructions or custom notes. These steps ensure that you can capture and store custom information tied to shipping addresses for multi-shipping orders, and extend the functionality of Magento 2’s checkout process.
[![Magento Malware Removal](https://magecomp.com/blog/wp-content/uploads/2025/02/Magento-Malware-Removal-CTA-3.webp)](https://magecomp.com/magento-malware-removal.html)

**Happy Coding!**


---

_View the original post at: [https://magecomp.com/blog/magento-2-save-custom-field-value-to-quote-address-for-multi-shipping-orders/](https://magecomp.com/blog/magento-2-save-custom-field-value-to-quote-address-for-multi-shipping-orders/)_  
_Served as markdown by [Third Audience](https://github.com/third-audience) v3.5.3_  
_Generated: 2026-08-17 00:43:18 UTC_  
