Open
Description
Preconditions and environment
- Magento versions: 2.4.8-beta1, 2.4.7, 2.4.7-p3, 2.4.7-p2, 2.4.7-p1, 2.4.7-beta3, 2.4.7-beta2, 2.4.7-beta1, 2.4.6, 2.4.6-p8, 2.4.6-p7, 2.4.6-p6, 2.4.6-p5, 2.4.6-p4, 2.4.6-p3, 2.4.6-p2, 2.4.6-p1
- Anything else that would help a developer reproduce the bug
Steps to reproduce
- Navigate to
Stores -> Configuration -> Customers -> Customer Configuration
. - Ensure you are in the Default Config scope.
- Navigate to
Name and Address Options -> Show Company
, and set it to No.
- Save the configuration.
- Switch to the Website scope.
- Navigate to
Name and Address Options -> Show Company
, and set it to Optional or Required.
- Save the configuration.
- Clear the configuration cache.
- Log in as a customer on the storefront (on a website where the company field for the address entity is set to Optional or Required).
- Add a product to the cart.
- Proceed to the checkout and navigate to the shipping step.
- Add a new shipping address and populate the Company name field.
- Choose a shipping method.
- Navigate to the payment step.
- Check the
quote_address
database table for the current quote. The company field is empty, but it is expected to contain the value provided by the customer. - Choose a payment method.
- Place the order.
- Navigate to the
Customer Account Page -> Address Book
. - Edit the address created during the checkout process.
- The Company field is empty, but it is expected to contain the value provided by the customer.
Screen.Recording.2024-12-03.at.11.51.27.mov
Expected result
- After navigating to the payment step with the new address selected, the corresponding row in the
quote_address
table must contain the company name provided by the customer. - After successfully completing the checkout process, the shipping address in the placed order must include the company name provided by the customer.
- If the
Save in address book
option is selected for the new address, the company field must be populated with the value provided by the customer.
Actual result
- After navigating to the payment step with the new address selected, the corresponding row in the
quote_address
table contains an empty value for the company field. - After successfully completing the checkout process, the shipping address in the placed order does not include the company name.
- If the
Save in address book
option is selected for the new address, the company field of the newly created address in the address book contains an empty value.
Additional information
This issue was introduced by changes made in the following commit: 039bf9b.
Reason: When checking if the company field should be shown for the address entity, the default scope is used. However, this field is configurable at both the default and website scopes. If the field is set to Not Visible in the default scope and configured with a different value (e.g., Optional or Required) at the website scope, the configuration at the website scope is ignored.
You can apply the following patch to resolve this issue:
Subject: [PATCH] Generated by Magento and Adobe Commerce PhpStorm by Atwix plugin
---
Index: vendor/magento/module-quote/Model/ShippingAddressManagement.php
===================================================================
diff --git a/vendor/magento/module-quote/Model/ShippingAddressManagement.php b/vendor/magento/module-quote/Model/ShippingAddressManagement.php
--- a/vendor/magento/module-quote/Model/ShippingAddressManagement.php
+++ b/vendor/magento/module-quote/Model/ShippingAddressManagement.php (date 1733221123066)
@@ -10,6 +10,7 @@
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Exception\InputException;
use Magento\Framework\Exception\NoSuchEntityException;
+use Magento\Store\Model\ScopeInterface;
use Psr\Log\LoggerInterface as Logger;
/**
@@ -93,8 +94,7 @@
$saveInAddressBook = $address->getSaveInAddressBook() ? 1 : 0;
$sameAsBilling = $address->getSameAsBilling() ? 1 : 0;
$customerAddressId = $address->getCustomerAddressId();
- if ($saveInAddressBook &&
- !$this->scopeConfig->getValue(Customer::XML_PATH_CUSTOMER_ADDRESS_SHOW_COMPANY)) {
+ if ($saveInAddressBook && !$this->isCompanyFieldVisibleForAddress()) {
$address->setCompany(null);
}
$this->addressValidator->validateForCart($quote, $address);
@@ -139,4 +139,17 @@
/** @var \Magento\Quote\Model\Quote\Address $address */
return $quote->getShippingAddress();
}
+
+ /**
+ * Determine whether the company field should be displayed for the customer address.
+ *
+ * @return bool
+ */
+ private function isCompanyFieldVisibleForAddress(): bool
+ {
+ return !!$this->scopeConfig->getValue(
+ Customer::XML_PATH_CUSTOMER_ADDRESS_SHOW_COMPANY,
+ ScopeInterface::SCOPE_WEBSITE
+ );
+ }
}
Release note
No response
Triage and priority
- Severity: S0 - Affects critical data or functionality and leaves users without workaround.
- Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
- Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
- Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
- Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.