diff --git a/inc/checkout/signup-fields/class-signup-field-site-url.php b/inc/checkout/signup-fields/class-signup-field-site-url.php index e0fb59a55..7659c6bf4 100644 --- a/inc/checkout/signup-fields/class-signup-field-site-url.php +++ b/inc/checkout/signup-fields/class-signup-field-site-url.php @@ -239,6 +239,17 @@ public function get_fields() { ], ], 'available_domains' => [ + 'order' => 30, + 'type' => 'text', + 'title' => __('Available Domain', 'ultimate-multisite'), + 'desc' => __('The domain used as the base for auto-generated subsite URLs.', 'ultimate-multisite'), + 'value' => $current_site->domain, + 'tab' => 'content', + 'wrapper_html_attr' => [ + 'v-show' => 'auto_generate_site_url', + ], + ], + 'available_domains_multi' => [ 'order' => 30, 'type' => 'textarea', 'title' => __('Available Domains', 'ultimate-multisite'), @@ -295,6 +306,23 @@ public function to_fields_array($attributes) { 'value' => 'autogenerate', ], ]; + + /* + * When available_domains is configured, inject a hidden site_domain + * field so the checkout session uses the correct base domain instead + * of falling back to $current_site->domain (the network primary). + * + */ + $domain = trim(wu_get_isset($attributes, 'available_domains', '')); + + if (! empty($domain)) { + $checkout_fields['site_domain'] = [ + 'type' => 'hidden', + 'id' => 'site_domain', + 'value' => $domain, + ]; + } + if (! empty($attributes['display_url_preview_with_auto'])) { $content = wu_get_template_contents('legacy/signup/steps/step-domain-url-preview'); @@ -350,8 +378,8 @@ public function to_fields_array($attributes) { ]; } - if ($attributes['available_domains'] && $attributes['enable_domain_selection']) { - $options = $this->get_domain_options($attributes['available_domains']); + if (! empty($attributes['available_domains_multi']) && $attributes['enable_domain_selection']) { + $options = $this->get_domain_options($attributes['available_domains_multi']); $checkout_fields['site_domain'] = [ 'name' => __('Domain', 'ultimate-multisite'),