Jump to content

How to set registration field required?


fredol

Recommended Posts

  • 3 weeks later...

@fredol

We have provided a solution to make the company field required. Please follow the steps below:

Step 1: Create a Clean Override File
Path: Ensure your override file is located at override/classes/form/CustomerFormatter.php.

Step 2: Copy the code below into the file, ensuring the correct PHP syntax:
 

<?php


// File: override/classes/form/CustomerFormatter.php


class CustomerFormatter extends CustomerFormatterCore {
    public function getFormat()
    {
        // Get the default format defined by the core
        $format = parent::getFormat();


        // Loop through each FormField object in the format
        foreach ($format as $field) {
            // Check if this FormField is the 'company' field
            if ($field->getName() === 'company') {
                // Set the company field as required
                $field->setRequired(true);
            }
        }


        return $format;
    }
}
?>

Step 3: In your PrestaShop admin panel, go to Advanced Parameters > Performance and click Clear Cache.

Step 4: Visit the registration page on the front end to verify. Please review the screenshot for reference.

We hope this solution works for you!
 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...