Jump to content

[Tutorial] [PS 1.7+] Removing account creation options on checkout

Recommended Posts

Version: Prestashop 1.7+
Tutorial last update: 29/05/2019

We have noticed that more and more the question is raised in prestashop forum how you can remove account creation in the checkout page.
We will describe below how and where you can disable / remove these components.
We strongly recommend that you always make a backup of the files that you change.
We also always recommend that you disable code blocks and not remove them. This allows you to later, if desired, to turn everything back

Step 1: Removing the option to create an account on the order page.
File location: YOURSTORE/classes/form/CustomerFormatter.php


Find and disable / remove the code below, to disable use the code tags: /* THE CODE LINES */

        if ($this->ask_for_password) {
            $format['password'] = (new FormField())
                        'Password', [], 'Shop.Forms.Labels'

In the same file (CustomerFormatter.php) you can find and disable following fields:
Social field ($genders), firstname, lastname, email, birthday, optin

Step 2: Removing the tab's "Order as a guest" and / or "Sign in".
File location: YOURSTORE/themes/YOURTHEME/templates/checkout/_partials/steps/ personal-information.tpl”


Find and disable / remove the code below, to disable use the code tags: {* THE CODE LINES *}

    <ul class="nav nav-inline my-2" role="tablist">
      <li class="nav-item">
          class="nav-link {if !$show_login_form}active{/if}"
          {if !$show_login_form} aria-selected="true"{/if}
          {if $guest_allowed}
            {l s='Order as a guest' d='Shop.Theme.Checkout'}
            {l s='Create an account' d='Shop.Theme.Customeraccount'}

      <li class="nav-item">
        <span href="nav-separator"> | </span>

      <li class="nav-item">
          class="nav-link {if $show_login_form}active{/if}"
          {if $show_login_form} aria-selected="true"{/if}
          {l s='Sign in' d='Shop.Theme.Actions'}

Step 3: Removing the block "Save time on your next order, sign up now".
File location: YOURSTORE/themes/YOURTHEME/templates/templates/checkout/order-confirmation.tpl”


Find and disable / remove the code below, to disable use the code tags: {* THE CODE LINES *}

  {block name='customer_registration_form'}
    {if $customer.is_guest}
      <div id="registration-form" class="card">
        <div class="card-block">
          <h4 class="h4">{l s='Save time on your next order, sign up now' d='Shop.Theme.Checkout'}</h4>
          {render file='customer/_partials/customer-form.tpl' ui=$register_form}

Another field within "checkout" which you want to delete?
post your question below so we can add it to our tutorial.

WARNING: Please make sure to clear your store cache (Advanced parameter >> Performance >> Clear Cache) and your browser cookies to see the changes!

---------------- PS: a like and a thank you for my work is appreciated ----------------

Edited by Crezzur (see edit history)
  • Like 2
  • Thanks 1

Share this post

Link to post
Share on other sites

Thank you very much for this tutorial, it is very helpful. You explain like a real pro 👍

I have a few question, i try to do myself but i stuck :)

1.  how to make telephone number field required?

2. How to make payment radio button selected by default, so i can remove payment step like i remove shipping step?

3. Can all steps be combined into one, so customer fill all information and click pay. No need for pressing 3 time button (Name, Address and Pay)

Thank you


Share this post

Link to post
Share on other sites

@zox First of all glad to hear that this tutorial helped you out!

Lets follow the steps below to make the changes you asked

1. Telephone number required
File location: YOURSTORE/classes/form/CustomerAddressFormatter.php

Search for and add the code :

    } elseif ($field === 'phone') {
        // ADD CODE BELOW TO CustomerAddressFormatter.php

Adding "$formField->setRequired(true);" will tell the form the field "phone" is required.
You can find all fields from the Addresses block in checkout in the file CustomerAddressFormatter.php.
You can add or remove the "$formField->setRequired(true);" to change if the field is required to proceed or not.

2. Payment radio button selected
File location: YOURSTORE/themes/classic/templates/checkout/_partials/steps/payment.tpl
Search for:

{if $selected_payment_option == $option.id || $is_free} checked {/if}

Change to: ("payment-option-2" means option 2 will be selected, change to required option)

{if $option.id == 'payment-option-2'} checked {/if}

3. Combine all steps
Will look into this later on

Edited by Crezzur (see edit history)

Share this post

Link to post
Share on other sites

Hi Crezzur, Thank you for answer

The phone field is now required and it work. But the radio button do not work. I try in a classic theme but button is never selected. I try payment-option-1 and payment-option-2. (I have only one payment option).

After that i try same code change in my template, and radio button is selected automatically, but i can not press button to continue... it is grayed out. Please see image.



Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More