Create a popup after successful new user registration prestashop

To create a popup after successful new user registration in PrestaShop, you'll need to use a combination of PrestaShop's built-in features and some custom coding. Here's a step-by-step guide to help you achieve this:

Step 1: Create a new module

In your PrestaShop installation, go to Modules > Module Manager and click on Add a new module. Fill in the required information, such as the module name, description, and version. Choose Front office as the module type.

Step 2: Create a new controller

In the module directory, create a new file called controllers/front/RegistrationPopupController.php. This file will contain the logic for the popup.

Step 3: Define the controller

In RegistrationPopupController.php, add the following code:

class RegistrationPopupController extends ModuleFrontController
{
    public function init()
    {
        parent::init();
        $this->setTemplate('registration_popup.tpl');
    }

    public function postProcess()
    {
        // Check if the registration was successful
        if (Tools::getValue('submitAccount') && $this->registrationSuccessful()) {
            // Display the popup
            $this->displayPopup();
        }
    }

    private function registrationSuccessful()
    {
        // Check if the registration was successful (e.g., check if the user account was created)
        // You can use PrestaShop's built-in functions to check this
        return true; // Replace with your own logic
    }

    private function displayPopup()
    {
        // Display the popup template
        $this->setTemplate('registration_popup.tpl');
    }
}

Step 4: Create the popup template

In the module directory, create a new file called views/templates/front/registration_popup.tpl. This file will contain the HTML for the popup.

Step 5: Add the popup to the registration form

In views/templates/front/register.tpl, add the following code:

<form action="{$_SERVER['SCRIPT_NAME']}" method="post">
    <!-- Existing form fields -->
    <input type="submit" name="submitAccount" value="{l s='Register'}">
</form>

<!-- Add the popup script -->
<script>
    $(document).ready(function() {
        $('form[action="{$_SERVER['SCRIPT_NAME']}"]').submit(function() {
            $.ajax({
                type: 'POST',
                url: '{$_SERVER['SCRIPT_NAME']}',
                data: $(this).serialize(),
                success: function(data) {
                    if (data.success) {
                        // Display the popup
                        $('#registration-popup').modal('show');
                    }
                }
            });
            return false;
        });
    });
</script>

<!-- Add the popup HTML -->
<div id="registration-popup" class="modal fade" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">Registration Successful!</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <!-- Add your popup content here -->
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
            </div>
        </div>
    </div>
</div>

Step 6: Configure the module

Go back to the Module Manager and click on the Configure button next to your new module. In the configuration page, set the Display popup option to Yes.

That's it! Now, when a new user registers, they should see a popup after successful registration.