diff --git a/modules/checkout/src/Plugin/Commerce/CheckoutPane/Registration.php b/modules/checkout/src/Plugin/Commerce/CheckoutPane/Registration.php index 16d8005..7d84109 100644 --- a/modules/checkout/src/Plugin/Commerce/CheckoutPane/Registration.php +++ b/modules/checkout/src/Plugin/Commerce/CheckoutPane/Registration.php @@ -9,7 +9,7 @@ use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Session\AccountInterface; use Drupal\user\UserAuthInterface; -use Drupal\user\Entity\User; +use Drupal\user\UserInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\RequestStack; @@ -19,7 +19,6 @@ use Symfony\Component\HttpFoundation\RequestStack; * @CommerceCheckoutPane( * id = "registration", * label = @Translation("Guest registration after checkout"), - * default_step = "complete", * ) */ class Registration extends CheckoutPaneBase implements CheckoutPaneInterface, ContainerFactoryPluginInterface { @@ -134,7 +133,7 @@ class Registration extends CheckoutPaneBase implements CheckoutPaneInterface, Co $pane_form['register']['name'] = [ '#type' => 'textfield', '#title' => $this->t('Username'), - '#maxlength' => USERNAME_MAX_LENGTH, + '#maxlength' => UserInterface::USERNAME_MAX_LENGTH, '#description' => $this->t("Several special characters are allowed, including space, period (.), hyphen (-), apostrophe ('), underscore (_), and the @ sign."), '#required' => FALSE, '#attributes' => [ @@ -156,7 +155,7 @@ class Registration extends CheckoutPaneBase implements CheckoutPaneInterface, Co $pane_form['register']['actions'] = ['#type' => 'actions']; $pane_form['register']['actions']['register'] = [ '#type' => 'submit', - '#value' => $this->t('Save details'), + '#value' => $this->t('Create my account'), '#name' => 'commerce_checkout_registration_submit', ]; diff --git a/modules/checkout/templates/commerce-checkout-registration.html.twig b/modules/checkout/templates/commerce-checkout-registration.html.twig index 89374d4..8d9c8eb 100644 --- a/modules/checkout/templates/commerce-checkout-registration.html.twig +++ b/modules/checkout/templates/commerce-checkout-registration.html.twig @@ -11,7 +11,7 @@ #}
-

{%trans%}Save Your Details{%endtrans%}

+

{%trans%}Create an account?{%endtrans%}

{%trans%}Complete your account registration now to be able to access your order information at any time.{%endtrans%}

diff --git a/modules/checkout/tests/src/Functional/CheckoutOrderTest.php b/modules/checkout/tests/src/Functional/CheckoutOrderTest.php index e12589b..f72c238 100644 --- a/modules/checkout/tests/src/Functional/CheckoutOrderTest.php +++ b/modules/checkout/tests/src/Functional/CheckoutOrderTest.php @@ -290,6 +290,23 @@ class CheckoutOrderTest extends CommerceBrowserTestBase { * Tests that you can register after completing the order as a guest. */ public function testRegistrationAfterGuestOrderCheckout() { + // Enable the registration pane. + /** @var \Drupal\commerce_checkout\Entity\CheckoutFlowInterface $checkout_flow */ + $checkout_flow = $this->container + ->get('entity_type.manager') + ->getStorage('commerce_checkout_flow') + ->load('default'); + /** @var \Drupal\commerce_checkout\Plugin\Commerce\CheckoutFlow\CheckoutFlowInterface $checkout_flow_plugin */ + $checkout_flow_plugin = $checkout_flow->getPlugin(); + /** @var \Drupal\commerce_checkout\Plugin\Commerce\CheckoutPane\Registration $pane */ + $pane = $checkout_flow_plugin->getPane('registration'); + $pane->setConfiguration([]); + $pane->setStepId('complete'); + $checkout_flow_plugin_configuration = $checkout_flow_plugin->getConfiguration(); + $checkout_flow_plugin_configuration['panes']['registration'] = $pane->getConfiguration(); + $checkout_flow_plugin->setConfiguration($checkout_flow_plugin_configuration); + $checkout_flow->save(); + $this->drupalLogout(); $this->drupalGet($this->product->toUrl()->toString()); $this->submitForm([], 'Add to cart'); @@ -320,13 +337,13 @@ class CheckoutOrderTest extends CommerceBrowserTestBase { $this->assertSession()->pageTextContains('Your order number is 1. You can view your order on your account page when logged in.'); // Assert that the registration checkout pane is shown. - $this->assertSession()->pageTextContains('Save Your Details'); + $this->assertSession()->pageTextContains('Create an account?'); // Register. $this->submitForm([ 'registration[register][name]' => 'User name', 'registration[register][password][pass1]' => 'pass', 'registration[register][password][pass2]' => 'pass', - ], 'Save details'); + ], 'Create my account'); // Assert that the account was created successfully. $this->assertSession()->pageTextContains('Registration successful. You are now logged in.'); @@ -369,28 +386,28 @@ class CheckoutOrderTest extends CommerceBrowserTestBase { 'registration[register][name]' => '', 'registration[register][password][pass1]' => 'pass', 'registration[register][password][pass2]' => 'pass', - ], 'Save details'); + ], 'Create my account'); $this->assertSession()->pageTextContains('You must enter a username.'); $this->submitForm([ 'registration[register][name]' => 'User name', 'registration[register][password][pass1]' => '', 'registration[register][password][pass2]' => '', - ], 'Save details'); + ], 'Create my account'); $this->assertSession()->pageTextContains('Password field is required.'); $this->submitForm([ 'registration[register][name]' => 'User @#.``^ รน % name invalid', 'registration[register][password][pass1]' => 'pass', 'registration[register][password][pass2]' => 'pass', - ], 'Save details'); + ], 'Create my account'); $this->assertSession()->pageTextContains('The username contains an illegal character.'); $this->submitForm([ 'registration[register][name]' => 'User name', 'registration[register][password][pass1]' => 'pass', 'registration[register][password][pass2]' => 'pass', - ], 'Save details'); + ], 'Create my account'); $this->assertSession()->pageTextContains('The username User name is already taken.'); }