Description
Preconditions and environment
- Magento 2.4.8-p1
- guest checkout enabled
- company attribute configured as required
Steps to reproduce
- Configure company attribute as required (Stores > Configuration > Customer Configuration > Name and Address Options > Company > Required)
- Enable guest checkout (Stores > Configuration > Sales > Checkout > Checkout Options > Allow Guest Checkout = Yes)
- Add product to cart
- Proceed to checkout as guest
- Fill out all required fields including company field
- Place order
Expected result
- Order should be placed successfully since all required fields including company are filled.
Actual result
- Order placement fails with validation error: "Company" is a required value.
Additional information
Error occurs in: vendor/magento/module-quote/Model/CustomerManagement.php:180
Root cause: In the validateAddresses() method, when processing guest checkout, the code creates a customer address object from billing address data but fails to copy the company field:
// Lines 161-171 in CustomerManagement.php
$customerAddress->setFirstname($billingAddress->getFirstname());
$customerAddress->setLastname($billingAddress->getLastname());
$customerAddress->setStreet($billingAddress->getStreet());
$customerAddress->setCity($billingAddress->getCity());
$customerAddress->setPostcode($billingAddress->getPostcode());
$customerAddress->setTelephone($billingAddress->getTelephone());
$customerAddress->setCountryId($billingAddress->getCountryId());
// MISSING: $customerAddress->setCompany($billingAddress->getCompany());
$customerAddress->setCustomAttributes($billingAddress->getCustomAttributes());
The company value from the billing address is never transferred to the customer address object being validated, causing the required field validation to fail.
Workaround: Add the missing line:
$customerAddress->setCompany($billingAddress->getCompany());
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”.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status