719-286-0751 [email protected]

Fixing “firstname is required” at Place Order in Hyvä Checkout When the Address Is Filled In (Magento 2)

A shopper fills in the whole checkout, clicks Place Order and gets this:

Please check the shipping address information. firstname is required...

The address form on the screen is complete. If the shopper retypes one field and tries again, the order usually goes through. The same message can name the billing address instead. Nothing useful is logged, and the people who report it are your customers, so you tend to hear about it late.

We traced this on a Magento 2.4.8 store running Hyvä Checkout 1.3.11. It happened on production only, and staging could not reproduce it until we made one configuration change. The cause has two parts: parallel requests that overwrite each other’s copy of the quote address, and a checkout that does not send the on-screen address again before it places the order.

Need help with your Hyvä store?
If this problem is costing you orders or staff time, our senior Magento and Hyvä team can help you debug it and deploy a fix safely.
Contact us →

Why it happens

Hyvä Checkout is built from Magewire components. The shipping address form, the billing address form, the shipping methods, the totals and the payment method each send their own requests, and a fast shopper (or a browser autofill) makes several of them fire at nearly the same moment.

Whether those requests run one after another depends on your PHP sessions. File sessions lock, so one shopper’s requests wait in line. Redis sessions with disable_locking set to 1, which is common on production servers, let them run in parallel.

Each request loads the quote, and most of them save it. When Magento saves a quote address it writes every column of the row, not only the ones that changed. So a request that loaded the quote before the shopper’s name and street were stored will, a moment later, write its older and emptier copy over them. On our store the name, street and city came back empty while the country and region survived. We reproduced it on staging by letting the shipping form and the billing form save at the same time.

Hyvä Checkout does not notice the loss. Before the order is placed, its magewire-form validator saves an address form only when the browser still holds edits it has not sent yet. On every request the server also refills the form component from the address stored on the quote. The screen shows a complete address, the database holds a partial one, and Magento’s order validation correctly refuses it.

1. Confirm this is your problem

Check how sessions are stored on the server where it happens:

php -r '$s = (include "app/etc/env.php")["session"]; var_export([$s["save"] ?? null, $s["redis"]["disable_locking"] ?? null]);'

If that prints redis and 1, requests from one shopper can overlap. Then look at the address of a quote that just failed:

SELECT address_id, address_type, firstname, lastname, street, city, region_id, country_id
FROM quote_address
WHERE quote_id = 12345;

An address with a country and region but no name, street or city, for a shopper who says they typed everything, is the signature.

To reproduce it, give staging the same session settings as production. Our staging site used file sessions, which is why it never failed there. With unlocked Redis sessions, editing the shipping and billing forms in quick succession was enough.

2. Stop a request from writing back fields it did not change

The first part of the fix is a small module with one plugin on the quote address resource model. Before an existing address is saved, every address field that still holds the value this request loaded is refreshed from the row as it is now. Fields the request changed itself are written as they are.

<?php
declare(strict_types=1);

namespace Cadence\QuoteAddressGuard\Plugin;

use Magento\Framework\Model\AbstractModel;
use Magento\Quote\Model\Quote\Address;
use Magento\Quote\Model\ResourceModel\Quote\Address as AddressResource;

class KeepNewerAddressFields
{
    private const FIELDS = [
        'prefix', 'firstname', 'middlename', 'lastname', 'suffix', 'company', 'street', 'city', 'region',
        'region_id', 'postcode', 'country_id', 'telephone', 'fax', 'vat_id',
    ];

    public function beforeSave(AddressResource $subject, AbstractModel $address): void
    {
        if (!$address instanceof Address || !$address->getId() || $address->isDeleted() || $address->getOrigData() === null) {
            return;
        }

        $untouched = [];
        foreach (self::FIELDS as $field) {
            if (self::normalise($address->getData($field)) === self::normalise($address->getOrigData($field))) {
                $untouched[] = $field;
            }
        }
        if (!$untouched) {
            return;
        }

        $connection = $subject->getConnection();
        $stored = $connection->fetchRow(
            $connection->select()->from($subject->getMainTable(), $untouched)->where('address_id = ?', (int)$address->getId())
        );
        if (!$stored) {
            return;
        }

        foreach ($untouched as $field) {
            if (self::normalise($stored[$field] ?? null) !== self::normalise($address->getData($field))) {
                $address->setData($field, $stored[$field]);
            }
        }
    }

    /** null, '' and an empty street array are the same "empty"; a street array equals its stored lines. */
    private static function normalise(mixed $value): string
    {
        if (is_array($value)) {
            $value = implode("\n", $value);
        }

        return trim((string)$value);
    }
}

It is wired in the module’s etc/di.xml:

<type name="Magento\Quote\Model\ResourceModel\Quote\Address">
    <plugin name="cadence_quoteaddressguard_keep_newer_fields"
            type="Cadence\QuoteAddressGuard\Plugin\KeepNewerAddressFields"/>
</type>

The plugin costs one small query per address save. It does not lock anything, so the checkout stays as fast as it was.

Need help with your Hyvä store?
If this problem is costing you orders or staff time, our senior Magento and Hyvä team can help you debug it and deploy a fix safely.
Contact us →

3. Make Hyvä Checkout send the form again before Place Order

The plugin stops the overwrite. The second part repairs an address that is already incomplete, whatever the reason. It is a composer patch to hyva-themes/magento2-hyva-checkout, in src/view/frontend/templates/page/js/api/v1/alpinejs/magewire-form-component.phtml. Inside the magewire-form validator, right before the existing check on form.__livewire.deferredActions, we add:

if (form.__livewire) {
    const fields = Array.from(form.querySelectorAll('input[wire\\:model\\.defer], textarea[wire\\:model\\.defer]'))
        .filter(field => ! ['checkbox', 'radio', 'hidden'].includes(field.type));

    if (fields.length !== 0) {
        fields.forEach(field => field.dispatchEvent(new Event('input', { bubbles: true })));
        await new Promise(resolve => setTimeout(resolve, 300));
    }
}

An input event makes Magewire queue the field’s current value. The short wait covers the debounce on deferred fields. The save that already follows then carries the whole form, so the address is stored again right before the order is placed. Selects are left out on purpose: country and region were never lost, and sending them again would run their update hooks.

Do not edit the file in vendor. Register the change with cweagans/composer-patches so it survives every composer install:

"extra": {
    "patches": {
        "hyva-themes/magento2-hyva-checkout": {
            "Address forms send their fields again before Place Order": "patches/hyva-checkout-resend-address.patch"
        }
    }
}

4. Verify on staging

With staging on the same session settings as production, we ran three checks with real test orders:

  • Without the fix, blanking the stored address and clicking Place Order gives the exact message customers reported.
  • With the fix, the same test restores the address, and the order is placed with both addresses complete.
  • A normal order with nothing tampered with still goes through, with a flat rate and with a live carrier rate.

Notes before you ship this

  • Turning session locking back on would hide the problem, but every checkout request would then wait for the one before it. We kept sessions unlocked and made the write safe instead.
  • The patch was cut against Hyvä Checkout 1.3.11. As of December 2026 the newest 1.3 release, 1.3.16, has the same validator code, so the patch is still needed there. Hyvä Checkout 3 rewrote this validator (in 3.0.2 it still saves a form only when the component has unsent changes), so the patch does not apply to it as written, and we have not tested version 3. The plugin from step 2 does not depend on the Hyvä Checkout version.
  • The template is marked internal by the vendor, so expect to re-cut the patch when you upgrade.
  • If staging uses file sessions and production uses unlocked Redis sessions, staging cannot show you this class of bug. Make them match.
Install our webapp on your iPhone! Tap and then Add to homescreen.
Share This