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 @@
- escapeHtml(__('Address Book')) ?> - escapeHtml(__('Manage Addresses')) ?> + escapeHtml(__('Address Book')) ?> + + escapeHtml(__('Manage Addresses')) ?> +
- escapeHtml(__('Default Billing Address')) ?> + escapeHtml(__('Default Billing Address')) ?>
@@ -22,12 +24,17 @@
- escapeHtml(__('Default Shipping Address')) ?> + escapeHtml(__('Default Shipping Address')) ?>
@@ -35,7 +42,12 @@
diff --git a/app/code/Magento/Customer/view/frontend/templates/address/book.phtml b/app/code/Magento/Customer/view/frontend/templates/address/book.phtml index e8fad1fe778db..e0c71eff05fbf 100644 --- a/app/code/Magento/Customer/view/frontend/templates/address/book.phtml +++ b/app/code/Magento/Customer/view/frontend/templates/address/book.phtml @@ -1,4 +1,5 @@
+ href=" + escapeUrl($block->getAddressEditUrl($defaultBillingAddress) . '?billingAddress') + ?>"> escapeHtml(__('Change Billing Address')) ?>
@@ -50,7 +53,9 @@
+ href=" + escapeUrl($block->getAddressEditUrl($defaultShippingAddress) . '?shippingAddress') ?> + "> escapeHtml(__('Change Shipping Address')) ?>
diff --git a/app/code/Magento/Customer/view/frontend/templates/address/edit.phtml b/app/code/Magento/Customer/view/frontend/templates/address/edit.phtml index a958f831e18a8..67f3c201a72b7 100644 --- a/app/code/Magento/Customer/view/frontend/templates/address/edit.phtml +++ b/app/code/Magento/Customer/view/frontend/templates/address/edit.phtml @@ -1,6 +1,6 @@ getViewModel(); $regionProvider = $block->getRegionProvider(); ?> +getRequest()->getParam('shippingAddress') !== null) ? 1 : 0; +$defaultBilling = ($block->getRequest()->getParam('billingAddress') !== null) ? 1 : 0; +?> getLayout()->createBlock(\Magento\Customer\Block\Widget\Company::class) ?> getLayout()->createBlock(\Magento\Customer\Block\Widget\Telephone::class) ?> getLayout()->createBlock(\Magento\Customer\Block\Widget\Fax::class) ?> @@ -31,11 +35,11 @@ $regionProvider = $block->getRegionProvider(); trim(str_replace('required-entry', '', $_streetValidationClass)) : ''; ?> addressGetAttributeValidationClass('region'); ?>
+ action="escapeUrl($block->getSaveUrlWithParams($defaultShipping, $defaultBilling)) ?>" + method="post" + id="form-validate" + enctype="multipart/form-data" + data-hasrequired="escapeHtmlAttr(__('* Required Fields')) ?>">
escapeHtml(__('Contact Information')) ?>
getBlockHtml('formkey') ?>