Description
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!
- Set up a Magento store with prefixes enabled in the customer configuration
- Go to checkout as a guest customer
- Select a prefix (e.g., "Herr" or "Frau") in the shipping/billing address form
- Complete the checkout process
- 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
Assignees
Labels
Type
Projects
Status