_customerAddress = $customerAddress; $this->_coreRegistry = $coreRegistry; } /** * Address before save event handler * * @param \Magento\Framework\Event\Observer $observer * @return void */ public function execute(\Magento\Framework\Event\Observer $observer) { if ($this->_coreRegistry->registry(self::VIV_CURRENTLY_SAVED_ADDRESS)) { $this->_coreRegistry->unregister(self::VIV_CURRENTLY_SAVED_ADDRESS); } /** @var $customerAddress Address */ $customerAddress = $observer->getCustomerAddress(); if ($customerAddress->getId()) { $this->_coreRegistry->register(self::VIV_CURRENTLY_SAVED_ADDRESS, $customerAddress->getId()); } else { $configAddressType = $this->_customerAddress->getTaxCalculationAddressType(); $forceProcess = $configAddressType == AbstractAddress::TYPE_SHIPPING ? $customerAddress->getIsDefaultShipping() : $customerAddress->getIsDefaultBilling(); if ($forceProcess) { $customerAddress->setForceProcess(true); } else { $this->_coreRegistry->register(self::VIV_CURRENTLY_SAVED_ADDRESS, 'new_address'); } } } }