I have added a new shipping address (without saving it in the address book) on the checkout page to place an order.
I want to update the existing default shipping address value (zone attribute only) from the new address after the order is successful.
I have used an event: checkout_onepage_controller_success_action
Observer code to set the zone attribute value
$addressFactory = $this->objectManager->get('\Magento\Customer\Model\AddressFactory');
$address = $addressFactory->create();
if($orderedZone != $existingZone && $existingZone != ''){
$address->setZone($newZone);
$address->save($address);
}
But after this code I am getting an error like this:
Exception #0 (Magento\Framework\Validator\Exception): "Country" is a required value.
"First Name" is a required value.
"Last Name" is a required value.
"Zip/Postal Code" is a required value.
"Street Address" is a required value.
These fields are already set in the default shipping address.
how can I set only the zone attribute from the new address?