Skip to content

company field validation fails for guest checkout #40011

Open
@my-brain-qlicks

Description

@my-brain-qlicks

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

No one assigned

    Labels

    Area: B2BComponent: CheckoutIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P1Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing.Reported on 2.4.8Indicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branch

    Type

    No type

    Projects

    Status

    Ready for Development

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions