diff --git a/app/code/Magento/Customer/Block/Address/Edit.php b/app/code/Magento/Customer/Block/Address/Edit.php index 993f3ff197fda..296d62f9ac3ae 100644 --- a/app/code/Magento/Customer/Block/Address/Edit.php +++ b/app/code/Magento/Customer/Block/Address/Edit.php @@ -1,8 +1,10 @@ getSaveUrlWithParams(); + } + + /** + * Return the Url for saving with parameters. + * + * @param int $defaultShipping Default shipping flag + * @param int $defaultBilling Default billing flag + * @return string + */ + public function getSaveUrlWithParams($defaultShipping = 0, $defaultBilling = 0) + { + $queryParams = ['_secure' => true]; + + // Consolidate $defaultShipping and $defaultBilling conditions + if ($defaultShipping == 1) { + $queryParams['default_shipping'] = 1; + } + if ($defaultBilling == 1) { + $queryParams['default_billing'] = 1; + } + + // Add 'id' parameter only if the address is not both default billing and shipping + if (!$this->getAddress()->isDefaultBilling() || !$this->getAddress()->isDefaultShipping()) { + $queryParams['id'] = $this->getAddress()->getId(); + } + + // URL construction remains in a single block return $this->_urlBuilder->getUrl( 'customer/address/formPost', - ['_secure' => true, 'id' => $this->getAddress()->getId()] + $queryParams ); } diff --git a/app/code/Magento/Customer/view/frontend/templates/account/dashboard/address.phtml b/app/code/Magento/Customer/view/frontend/templates/account/dashboard/address.phtml index d306e8c7c734f..dfe49859159f2 100644 --- a/app/code/Magento/Customer/view/frontend/templates/account/dashboard/address.phtml +++ b/app/code/Magento/Customer/view/frontend/templates/account/dashboard/address.phtml @@ -1,6 +1,6 @@