From 8f3c0ed36066832a5f29a87f27e0d3e24ddb3a8c Mon Sep 17 00:00:00 2001 From: Anna Heath Date: Fri, 18 Jul 2025 21:54:45 -0700 Subject: [PATCH] Delay registering commerce_customer addressfield Fixes #42 This is an issue with the timing of things! If we haven't already enabled addressfield when we enable commerce_customer, Backdrop tries to register field_commerce_customer_address.json from the config directory before the addressfield module has made the addressfield field type available. This results in an error that the addressfield module isn't available (which it isn't!). We need to delay the loading of the field config file until all modules are fully installed and field types are registered, and we can do that by moving it to a hook_update(). We need to move that config file into a subdirectory of config, which I'm not crazy about, but this works. --- modules/customer/commerce_customer.install | 9 +++++++++ .../field.field.field_commerce_customer_address.json | 0 2 files changed, 9 insertions(+) rename modules/customer/config/{ => install_later}/field.field.field_commerce_customer_address.json (100%) diff --git a/modules/customer/commerce_customer.install b/modules/customer/commerce_customer.install index 168da9a1..f0384675 100644 --- a/modules/customer/commerce_customer.install +++ b/modules/customer/commerce_customer.install @@ -244,3 +244,12 @@ function commerce_customer_update_1002() { $config->save(); } } + +function commerce_customer_update_1003() { + $config_name = 'field.field.field_commerce_customer_address'; + $path = backdrop_get_path('module', 'commerce_customer') . '/config/install_later/' . $config_name . '.json'; + $data = json_decode(file_get_contents($path), TRUE); + if (config($config_name)->isNew()) { + config($config_name)->setData($data)->save(); + } +} diff --git a/modules/customer/config/field.field.field_commerce_customer_address.json b/modules/customer/config/install_later/field.field.field_commerce_customer_address.json similarity index 100% rename from modules/customer/config/field.field.field_commerce_customer_address.json rename to modules/customer/config/install_later/field.field.field_commerce_customer_address.json