From 10e1fa19754fe10510576ab38f3bba46ec054d27 Mon Sep 17 00:00:00 2001 From: David Stone Date: Thu, 11 Jun 2026 14:58:34 -0600 Subject: [PATCH] fix: clarify checkout step loading copy --- assets/js/checkout.js | 6 ++++- inc/checkout/class-checkout.php | 2 ++ lang/ultimate-multisite.pot | 4 ++++ tests/unit/Checkout_Step_Fields_Test.php | 30 +++++++++++++++++++++++- 4 files changed, 40 insertions(+), 2 deletions(-) diff --git a/assets/js/checkout.js b/assets/js/checkout.js index 5ed52d399..ed5b1235e 100644 --- a/assets/js/checkout.js +++ b/assets/js/checkout.js @@ -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 = '
' + '
' + '
' + - (wu_checkout.i18n.provisioning_site || 'Provisioning your site — this can take up to 60 seconds.') + + loadingText + '
' + '
'; diff --git a/inc/checkout/class-checkout.php b/inc/checkout/class-checkout.php index da863c376..e0ed2a2c2 100644 --- a/inc/checkout/class-checkout.php +++ b/inc/checkout/class-checkout.php @@ -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'), @@ -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(), ]; /* diff --git a/lang/ultimate-multisite.pot b/lang/ultimate-multisite.pot index 373c53b42..5e7587abd 100644 --- a/lang/ultimate-multisite.pot +++ b/lang/ultimate-multisite.pot @@ -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 diff --git a/tests/unit/Checkout_Step_Fields_Test.php b/tests/unit/Checkout_Step_Fields_Test.php index c29d1843a..2315ad64f 100644 --- a/tests/unit/Checkout_Step_Fields_Test.php +++ b/tests/unit/Checkout_Step_Fields_Test.php @@ -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( [ @@ -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(); @@ -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']; } @@ -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.'); + } }