Skip to content

Guest Prefix Not Saved to Quote Address 2.4.8 #39915

Open
@ajung2

Description

@ajung2

Summary

Guest Prefix Not Saved During Checkout

I've discovered an issue where prefix/salutation values (Herr/Frau) selected by guest customers during checkout are not being saved to the quote object and subsequently not appearing in orders.

We are using Magento 2.4.8 with Hyvä Checkout, and while customers can select a prefix in the checkout form, this value disappears before reaching the final order. All other address fields (first name, last name, street, etc.) transfer correctly.

The issue appears to be in how the prefix value is handled specifically for guest customers. The code in CustomerManagement::validateAddresses() attempts to set the prefix but the value is lost somewhere in the process:

if (empty($addresses) && $quote->getCustomerIsGuest()) {
    $billingAddress = $quote->getBillingAddress();
    $customerAddress = $this->customerAddressFactory->create();
    $customerAddress->setFirstname($billingAddress->getFirstname());
    // ...other fields...
}

I've confirmed this affects our Magento 2.4.8 installation using Hyvä Checkout with guest customers. The issue doesn't occur for logged-in customers, whose prefix values are correctly saved.

Examples

Steps to Reproduce and working patch!

  1. Set up a Magento store with prefixes enabled in the customer configuration
  2. Go to checkout as a guest customer
  3. Select a prefix (e.g., "Herr" or "Frau") in the shipping/billing address form
  4. Complete the checkout process
  5. Error Msg with "Prefix" not set

patch

diff --git a/vendor/magento/module-quote/Model/CustomerManagement.php b/vendor/magento/module-quote/Model/CustomerManagement.php
index dfeee78d7..d8d43e16b 100644
--- a/vendor/magento/module-quote/Model/CustomerManagement.php
+++ b/vendor/magento/module-quote/Model/CustomerManagement.php
@@ -162,6 +162,7 @@ class CustomerManagement
         if (empty($addresses) && $quote->getCustomerIsGuest()) {
             $billingAddress = $quote->getBillingAddress();
             $customerAddress = $this->customerAddressFactory->create();
+            $customerAddress->setPrefix($billingAddress->getPrefix());
             $customerAddress->setFirstname($billingAddress->getFirstname());
             $customerAddress->setLastname($billingAddress->getLastname());
             $customerAddress->setStreet($billingAddress->getStreet());

Proposed solution

The issue is in \Magento\Quote\Model\CustomerManagement::validateAddresses() 

$customerAddress = $this->customerAddressFactory->create();
$customerAddress->setPrefix($billingAddress->getPrefix()); // Add THIS! and it works
$customerAddress->setFirstname($billingAddress->getFirstname());

or

patch

diff --git a/vendor/magento/module-quote/Model/CustomerManagement.php b/vendor/magento/module-quote/Model/CustomerManagement.php
index dfeee78d7..d8d43e16b 100644
--- a/vendor/magento/module-quote/Model/CustomerManagement.php
+++ b/vendor/magento/module-quote/Model/CustomerManagement.php
@@ -162,6 +162,7 @@ class CustomerManagement
         if (empty($addresses) && $quote->getCustomerIsGuest()) {
             $billingAddress = $quote->getBillingAddress();
             $customerAddress = $this->customerAddressFactory->create();
+            $customerAddress->setPrefix($billingAddress->getPrefix());
             $customerAddress->setFirstname($billingAddress->getFirstname());
             $customerAddress->setLastname($billingAddress->getLastname());
             $customerAddress->setStreet($billingAddress->getStreet());

Release note

Fixed guest customer prefix (Mr/Mrs) not saving during checkout. Previously, salutations selected by guest customers were lost before reaching the final order, while all other address fields transferred correctly.

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

Labels

Area: Cart & CheckoutComponent: CheckoutIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P2A defect with this priority could have functionality issues which are not to expectations.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 branchTriage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject it

Type

No type

Projects

Status

Ready for Development

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions