Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion assets/js/checkout.js
Original file line number Diff line number Diff line change
Expand Up @@ -1702,10 +1702,14 @@
jQuery(this).find('button[type="submit"]').prop('disabled', true);

// Show loading message with status text
const loadingText = wu_checkout.is_last_step
? (wu_checkout.i18n.provisioning_site || 'Provisioning your site — this can take up to 60 seconds.')
: (wu_checkout.i18n.recording_responses || 'Recording Your Responses...');

const loadingMessage = '<div style="text-align: center;">' +
'<div class="spinner is-active wu-float-none" style="float: none !important; margin-bottom: 12px;"></div>' +
'<div style="font-size: 14px; line-height: 1.5;">' +
(wu_checkout.i18n.provisioning_site || 'Provisioning your site — this can take up to 60 seconds.') +
loadingText +
'</div>' +
'</div>';

Expand Down
2 changes: 2 additions & 0 deletions inc/checkout/class-checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -2112,6 +2112,7 @@ public function get_checkout_variables() {
'cancel' => __('Cancel', 'ultimate-multisite'),
'email_exists' => __('A customer with the same email address or username already exists.', 'ultimate-multisite'),
'provisioning_site' => __('Provisioning your site — this can take up to 60 seconds.', 'ultimate-multisite'),
'recording_responses' => __('Recording Your Responses...', 'ultimate-multisite'),
// Client-side validation messages (%s = field label, %d = numeric limit).
/* translators: %s: field label */
'field_required' => __('%s is required.', 'ultimate-multisite'),
Expand Down Expand Up @@ -2204,6 +2205,7 @@ public function get_checkout_variables() {
'needs_billing_info' => true,
'auto_renew' => true,
'products' => array_unique($products),
'is_last_step' => $this->is_last_step(),
];

/*
Expand Down
4 changes: 4 additions & 0 deletions lang/ultimate-multisite.pot
Original file line number Diff line number Diff line change
Expand Up @@ -8083,6 +8083,10 @@ msgstr ""
msgid "Provisioning your site — this can take up to 60 seconds."
msgstr ""

#: inc/checkout/class-checkout.php:2111
msgid "Recording Your Responses..."
msgstr ""

#. translators: %s: field label
#: inc/checkout/class-checkout.php:2113
#, php-format
Expand Down
30 changes: 29 additions & 1 deletion tests/unit/Checkout_Step_Fields_Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class Checkout_Step_Fields_Test extends TestCase {
*
* @return array
*/
private function build_step_fields_map(): array {
private function build_checkout_variables(string $step_name = 'account'): array {

$form = wu_create_checkout_form(
[
Expand Down Expand Up @@ -119,6 +119,8 @@ private function build_step_fields_map(): array {

// Inject the seeded form into the real checkout singleton (public prop).
$checkout->checkout_form = $form;
$checkout->steps = $form->get_steps_to_show();
$checkout->step_name = $step_name;

$vars = $checkout->get_checkout_variables();

Expand All @@ -128,6 +130,18 @@ private function build_step_fields_map(): array {
'get_checkout_variables() must expose step_fields so the Vue validator can scope validation per step. If this key is gone, Step 1 demands every field and registration is blocked.'
);

return $vars;
}

/**
* Builds and returns the step_fields checkout variable.
*
* @return array
*/
private function build_step_fields_map(): array {

$vars = $this->build_checkout_variables();

return $vars['step_fields'];
}

Expand Down Expand Up @@ -213,4 +227,18 @@ public function test_fields_are_partitioned_across_steps_not_collapsed(): void {
);
}
}

/**
* Guards the loading-copy decision used by the multi-step Vue form.
*/
public function test_checkout_variables_expose_step_specific_loading_copy(): void {

$account_vars = $this->build_checkout_variables('account');
$payment_vars = $this->build_checkout_variables('payment');

$this->assertArrayHasKey('recording_responses', $account_vars['i18n']);
$this->assertSame('Recording Your Responses...', $account_vars['i18n']['recording_responses']);
$this->assertFalse($account_vars['is_last_step'], 'The first step must not show the provisioning copy.');
$this->assertTrue($payment_vars['is_last_step'], 'The final step should keep the provisioning copy.');
}
}
Loading