Copy checkbox not ticked by default

Created on 11 July 2025, 3 months ago

Problem/Motivation

I want the "shipping same as billing" box to be ticked by default.

The code in alterForm() suggests that

// Copying is enabled by default for new billing profiles.

_but_ the check that it uses ($shipping_profile->isNew()) always returns false, as the order (and profile along with it) is saved by ShippingInformation:buildPaneForm()

Proposed resolution

As a workaround, I have implemented hook_entity_create():

  if ($entity->getEntityTypeId() != "profile") {
    return;
  }

  if ($entity->bundle() == "customer") {
    $entity->setData('copy_fields', TRUE);
  }

This works on this site because the billing profile is a different type. Not sure how to make this generic, as hook_entity_create() cannot see the context of where the profile is being used(?)

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇬🇧United Kingdom grahamC Oxford, UK

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024