Crezzur.com Posted May 29, 2019 Share Posted May 29, 2019 (edited) 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()) ->setName('password') ->setType('password') ->setLabel( $this->translator->trans( 'Password', [], 'Shop.Forms.Labels' ) ) ->setRequired($this->password_is_required) ; } 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"> <a class="nav-link {if !$show_login_form}active{/if}" data-toggle="tab" href="#checkout-guest-form" role="tab" aria-controls="checkout-guest-form" {if !$show_login_form} aria-selected="true"{/if} > {if $guest_allowed} {l s='Order as a guest' d='Shop.Theme.Checkout'} {else} {l s='Create an account' d='Shop.Theme.Customeraccount'} {/if} </a> </li> <li class="nav-item"> <span href="nav-separator"> | </span> </li> <li class="nav-item"> <a class="nav-link {if $show_login_form}active{/if}" data-link-action="show-login-form" data-toggle="tab" href="#checkout-login-form" role="tab" aria-controls="checkout-login-form" {if $show_login_form} aria-selected="true"{/if} > {l s='Sign in' d='Shop.Theme.Actions'} </a> </li> </ul> 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} </div> </div> {/if} {/block} 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 May 29, 2019 by Crezzur (see edit history) 3 2 Link to comment Share on other sites More sharing options...
zox Posted February 3, 2020 Share Posted February 3, 2020 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 Link to comment Share on other sites More sharing options...
Crezzur.com Posted February 3, 2020 Author Share Posted February 3, 2020 (edited) @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 requiredFile location: YOURSTORE/classes/form/CustomerAddressFormatter.php Search for and add the code : } elseif ($field === 'phone') { $formField->setType('tel'); // ADD CODE BELOW TO CustomerAddressFormatter.php $formField->setRequired(true); 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 selectedFile 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 February 3, 2020 by Crezzur (see edit history) Link to comment Share on other sites More sharing options...
zox Posted February 3, 2020 Share Posted February 3, 2020 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. Link to comment Share on other sites More sharing options...
reiter1981 Posted May 12, 2020 Share Posted May 12, 2020 Hello Crezzur! I would like to remove this form and the address form to jump directly to the shipping method by clicking on payment Thank you very much for your help! Link to comment Share on other sites More sharing options...
ingsk Posted June 5, 2020 Share Posted June 5, 2020 This tutorial worked for me, but it introduced something else. I've already spent hours trying to solve it and I suspect there is a easy solution. Any tips welcome! See screenshot. When I disable the modules GDPR and Newsletter, the bottom two text input fields seem to "think" they are the checkboxes that are no longer there. Ie they format with label on top and Email field is no longer mandatory - a huge issue for us. If I switch GDPR and Newsletter back on, the fields format correctly. How can I get rid of the "ghosts" of GDPR and Newsletter checkboxes? Have tried to unhook what I believe was carrying them, and disabled the modules. No luck! Thanks. Link to comment Share on other sites More sharing options...
ccristian Posted September 25, 2020 Share Posted September 25, 2020 (edited) Hi friends! First of all I want to thank you for your great turotial! I tried to remove the "firstname" and "lastname" filds, from the Checkout process, acording to your tutorial....and after I did that, it gives me this error (please see the picture attached)....I gues there are not optional filds. Here is how I disabled these fields: /*$format['firstname'] = (new FormField()) ->setName('firstname') ->setLabel( $this->translator->trans( 'First name', [], 'Shop.Forms.Labels' ) ) ->setRequired(true);*/ /*$format['lastname'] = (new FormField()) ->setName('lastname') ->setLabel( $this->translator->trans( 'Last name', [], 'Shop.Forms.Labels' ) ) ->setRequired(true);*/ Can someone tell me how do I remove those fields so I can move on to the next step of the checkout process? Thank you! Edited September 25, 2020 by ccristian translate corrections (see edit history) Link to comment Share on other sites More sharing options...
Crezzur.com Posted September 25, 2020 Author Share Posted September 25, 2020 @ccristianPlease enable your error debugging in order to see which error you have Link to comment Share on other sites More sharing options...
ccristian Posted September 25, 2020 Share Posted September 25, 2020 53 minutes ago, Crezzur said: @ccristianPlease enable your error debugging in order to see which error you have This is what I get with Debug mode enabled Link to comment Share on other sites More sharing options...
Crezzur.com Posted September 27, 2020 Author Share Posted September 27, 2020 @ccristian I have just tried it my self, in the file CustomerFormatter.php disable the full block like below. I receive no errors doing this and the fields firstname and lastname are removed. /* -- START REMOVE $format['firstname'] = (new FormField()) ->setName('firstname') ->setLabel( $this->translator->trans( 'First name', [], 'Shop.Forms.Labels' ) ) ->setRequired(true); $format['lastname'] = (new FormField()) ->setName('lastname') ->setLabel( $this->translator->trans( 'Last name', [], 'Shop.Forms.Labels' ) ) ->setRequired(true); END REMOVE -- */ Link to comment Share on other sites More sharing options...
ccristian Posted September 27, 2020 Share Posted September 27, 2020 9 hours ago, Crezzur said: @ccristian I have just tried it my self, in the file CustomerFormatter.php disable the full block like below. I receive no errors doing this and the fields firstname and lastname are removed. /* -- START REMOVE $format['firstname'] = (new FormField()) ->setName('firstname') ->setLabel( $this->translator->trans( 'First name', [], 'Shop.Forms.Labels' ) ) ->setRequired(true); $format['lastname'] = (new FormField()) ->setName('lastname') ->setLabel( $this->translator->trans( 'Last name', [], 'Shop.Forms.Labels' ) ) ->setRequired(true); END REMOVE -- */ I tried this too, and It doesn't working Link to comment Share on other sites More sharing options...
Crezzur.com Posted May 5, 2021 Author Share Posted May 5, 2021 For the people still searching for removing parts from the Adresses form i have writen a small tutorial on Stack Overflow. You can find this here: https://stackoverflow.com/a/67396914/3877838 Link to comment Share on other sites More sharing options...
ComGrafPL Posted May 31, 2021 Share Posted May 31, 2021 On 5/5/2021 at 9:49 AM, Crezzur said: For the people still searching for removing parts from the Adresses form i have writen a small tutorial on Stack Overflow. You can find this here: https://stackoverflow.com/a/67396914/3877838 Great guide. Is it possible to make all the steps in one page? Personal Info, Delivery, Payment, so client isnt forced to click after each step. Which is rather annoying for them. Link to comment Share on other sites More sharing options...
kolmen Posted February 6, 2022 Share Posted February 6, 2022 (edited) If i make 1 step i get an error 500 details in attachment Could you help? PS. It is worth adding in the tutorial so that the changed files are in the override folder, otherwise the changes will disappear after the update So the beter way for 1 step is this https://stackoverflow.com/questions/67834719/prestashop-1-7-how-to-remove-optional-password-for-registration-from-guest-check and add edited file to override/classes/form clear cache edit2:// if you change like attachment in link then you remove password form all form and you can not make new account.... so still dont have any idea how fix it @Crezzur.com Edited February 11, 2022 by kolmen (see edit history) Link to comment Share on other sites More sharing options...
Sairon Posted October 21, 2022 Share Posted October 21, 2022 I am getting the same error as @kolmen can anyone assist me in private please? Link to comment Share on other sites More sharing options...
MorpheusUno Posted October 22, 2022 Share Posted October 22, 2022 (edited) On 2/6/2022 at 6:07 PM, kolmen said: If i make 1 step i get an error 500 details in attachment Could you help? PS. It is worth adding in the tutorial so that the changed files are in the override folder, otherwise the changes will disappear after the update So the beter way for 1 step is this https://stackoverflow.com/questions/67834719/prestashop-1-7-how-to-remove-optional-password-for-registration-from-guest-check and add edited file to override/classes/form clear cache edit2:// if you change like attachment in link then you remove password form all form and you can not make new account.... so still dont have any idea how fix it @Crezzur.com Hi, Here is my solution to the issue you're having, i had this issue before and after searching files here's what i found out you need to remove.navigate: classes/form/customerform.tplcomment out this $passwordField = $this->getField('password'); if ((!empty($passwordField->getValue()) || $this->passwordRequired) && Validate::isPasswd($passwordField->getValue()) === false) { $passwordField->addError($this->translator->trans( 'Password must be between 5 and 72 characters long', [], 'Shop.Notifications.Error' )); }Hope this helps! Edited October 22, 2022 by MorpheusUno (see edit history) Link to comment Share on other sites More sharing options...
ccristian Posted November 26, 2022 Share Posted November 26, 2022 Hi to all! Does anybody knows how to hide the "Country" field from Checkout process? Since I have only 1 country activated for shipping I don't need this field to be shown in the checkout process. I tried to hide it from front office by adding the "display: none" property, but I didn't found the right code...I tried to remove it from Back Office > International > Countries > Address format and it's telling me that this field it's mandatory.... please help! My configuration is: PrestaShop version 1.7.8.7, Warehouse theme latest version (4.5.5), here is the link of the Warehouse style I am using: https://iqit-commerce.com/ps17/demo1/en/ Thank you! Link to comment Share on other sites More sharing options...
ccristian Posted January 3, 2023 Share Posted January 3, 2023 On 11/26/2022 at 8:28 AM, ccristian said: Hi to all! Does anybody knows how to hide the "Country" field from Checkout process? Since I have only 1 country activated for shipping I don't need this field to be shown in the checkout process. I tried to hide it from front office by adding the "display: none" property, but I didn't found the right code...I tried to remove it from Back Office > International > Countries > Address format and it's telling me that this field it's mandatory.... please help! My configuration is: PrestaShop version 1.7.8.7, Warehouse theme latest version (4.5.5), here is the link of the Warehouse style I am using: https://iqit-commerce.com/ps17/demo1/en/ Thank you! Solved my problem with this line of code: .form-group:has(#field-id_country) { display:none; } Link to comment Share on other sites More sharing options...
boba56 Posted March 25 Share Posted March 25 (edited) Hello, I followed some of the instructions here and also used chatGPT to delete thefields that I didn't wanted from checkout, but it didn't worked, nothing happend. I delete cache on the backoffice and browser too. Chatgpt also mentioned that there could be more related archives that will still show the fields. I don't know about PHP so I just doing copy paste. This is the actuall code on my CustomerFormatter.php Quote <?php /** * Copyright since 2007 PrestaShop SA and Contributors * PrestaShop is an International Registered Trademark & Property of PrestaShop SA * * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to [email protected] so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade PrestaShop to newer * versions in the future. If you wish to customize PrestaShop for your * needs please refer to https://devdocs.prestashop.com/ for more information. * * @author PrestaShop SA and Contributors <[email protected]> * @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ use Symfony\Component\Translation\TranslatorInterface; class CustomerFormatterCore implements FormFormatterInterface { private $translator; private $language; private $ask_for_birthdate = true; private $ask_for_partner_optin = true; private $partner_optin_is_required = true; private $ask_for_password = true; private $password_is_required = true; private $ask_for_new_password = false; public function __construct( TranslatorInterface $translator, Language $language ) { $this->translator = $translator; $this->language = $language; } public function setAskForBirthdate($ask_for_birthdate) { $this->ask_for_birthdate = $ask_for_birthdate; return $this; } public function setAskForPartnerOptin($ask_for_partner_optin) { $this->ask_for_partner_optin = $ask_for_partner_optin; return $this; } public function setPartnerOptinRequired($partner_optin_is_required) { $this->partner_optin_is_required = $partner_optin_is_required; return $this; } public function setAskForPassword($ask_for_password) { $this->ask_for_password = $ask_for_password; return $this; } public function setAskForNewPassword($ask_for_new_password) { $this->ask_for_new_password = $ask_for_new_password; return $this; } public function setPasswordRequired($password_is_required) { $this->password_is_required = $password_is_required; return $this; } public function getFormat() { $format = []; $genders = Gender::getGenders($this->language->id); if ($genders->count() > 0) { $genderField = (new FormField()) ->setName('id_gender') ->setType('radio-buttons') ->setLabel( $this->translator->trans( 'Social title', [], 'Shop.Forms.Labels' ) ); foreach ($genders as $gender) { $genderField->addAvailableValue($gender->id, $gender->name); } $format[$genderField->getName()] = $genderField; } $format['firstname'] = (new FormField()) ->setName('firstname') ->setLabel( $this->translator->trans( 'First name', [], 'Shop.Forms.Labels' ) ) ->setRequired(true) ->addAvailableValue( 'comment', $this->translator->trans('Only letters and the dot (.) character, followed by a space, are allowed.', [], 'Shop.Forms.Help') ); $format['lastname'] = (new FormField()) ->setName('lastname') ->setLabel( $this->translator->trans( 'Last name', [], 'Shop.Forms.Labels' ) ) ->setRequired(true) ->addAvailableValue( 'comment', $this->translator->trans('Only letters and the dot (.) character, followed by a space, are allowed.', [], 'Shop.Forms.Help') ); if (Configuration::get('PS_B2B_ENABLE')) { $format['company'] = (new FormField()) ->setName('company') ->setType('text') ->setLabel($this->translator->trans( 'Company', [], 'Shop.Forms.Labels' )); $format['siret'] = (new FormField()) ->setName('siret') ->setType('text') ->setLabel($this->translator->trans( // Please localize this string with the applicable registration number type in your country. For example : "SIRET" in France and "Código fiscal" in Spain. 'Identification number', [], 'Shop.Forms.Labels' )); } $format['email'] = (new FormField()) ->setName('email') ->setType('email') ->setLabel( $this->translator->trans( 'Email', [], 'Shop.Forms.Labels' ) ) ->setRequired(true); if ($this->ask_for_password) { $format['password'] = (new FormField()) ->setName('password') ->setType('password') ->setLabel( $this->translator->trans( 'Password', [], 'Shop.Forms.Labels' ) ) ->setRequired($this->password_is_required); } if ($this->ask_for_new_password) { $format['new_password'] = (new FormField()) ->setName('new_password') ->setType('password') ->setLabel( $this->translator->trans( 'New password', [], 'Shop.Forms.Labels' ) ); } if ($this->ask_for_birthdate) { $format['birthday'] = (new FormField()) ->setName('birthday') ->setType('text') ->setLabel( $this->translator->trans( 'Birthdate', [], 'Shop.Forms.Labels' ) ) ->addAvailableValue('placeholder', Tools::getDateFormat()) ->addAvailableValue( 'comment', $this->translator->trans('(E.g.: %date_format%)', ['%date_format%' => Tools::formatDateStr('31 May 1970')], 'Shop.Forms.Help') ); } if ($this->ask_for_partner_optin) { $format['optin'] = (new FormField()) ->setName('optin') ->setType('checkbox') ->setLabel( $this->translator->trans( 'Receive offers from our partners', [], 'Shop.Theme.Customeraccount' ) ) ->setRequired($this->partner_optin_is_required); } // ToDo, replace the hook exec with HookFinder when the associated PR will be merged $additionalCustomerFormFields = Hook::exec('additionalCustomerFormFields', ['fields' => &$format], null, true); if (is_array($additionalCustomerFormFields)) { foreach ($additionalCustomerFormFields as $moduleName => $additionnalFormFields) { if (!is_array($additionnalFormFields)) { continue; } foreach ($additionnalFormFields as $formField) { $formField->moduleName = $moduleName; $format[$moduleName . '_' . $formField->getName()] = $formField; } } } // TODO: TVA etc.? return $this->addConstraints($format); } private function addConstraints(array $format) { $constraints = Customer::$definition['fields']; foreach ($format as $field) { if (!empty($constraints[$field->getName()]['validate'])) { $field->addConstraint( $constraints[$field->getName()]['validate'] ); } } return $format; } } And these are the files on the same folder of the file CustomerFormatter.php (public_htm>classes>form) Edited March 25 by boba56 edit/ige repeated (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now