Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions inc/checkout/signup-fields/class-signup-field-site-url.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down Expand Up @@ -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');

Expand Down Expand Up @@ -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'),
Expand Down
Loading