Jump to content

How to delete customers when got an error


FerreireX

Recommended Posts

I need to know how to identify spam customers.
Can you give a list?
An example of why there is an error in lastname!
Then I'll give you a sample script on how to remove unwanted customers in bulk and how to handle their registration.

Link to comment
Share on other sites

Copy text and save to prestashop root folder.

This script removes fake customers and orders when the last name contains www in the name.

File name: fake-delete.php

<?php
    require(dirname(__FILE__).'/config/config.inc.php');
    
    $get_fake_customer = Db::getInstance()->executeS("SELECT id_customer FROM "._DB_PREFIX_."customer WHERE lastname LIKE '%www.%'");
    $result = '';
    
    foreach ($get_fake_customer as $fake_customer) {
        $customer = new Customer($fake_customer['id_customer']);
        if ($customer->delete()) {
            $result .= 'id customer: '.$fake_customer['id_customer'].' - DELETED'.'<br />';
            
            $get_order = Db::getInstance()->executeS('SELECT id_order FROM '._DB_PREFIX_.'orders WHERE id_customer = '.$fake_customer['id_customer']);
            if ($get_order) {
                foreach ($get_order as $orders) {
                    $order = new Order($orders['id_order']);
                    if ($order->delete()) {
                        $result .= 'id order: '.$orders['id_order'].' - DELETED'.'<br />';    
                    } else {
                        $result .= 'id order: '.$orders['id_order'].' - NOT DELETED'.'<br />';    
                    }     
                }
                
            }

        } else  {
            $result .= 'id customer: '.$fake_customer['id_customer'].' - NOT DELETED'.'<br />';
        }
        
    }
    
    echo $result;

 

Edited by Guest (see edit history)
Link to comment
Share on other sites

I'll write the antispam protection script for you tomorrow.
Unfortunately, I don't have time today.
I am sorry.
Just find reCaptcha for register and contact form on the forum.

Link to comment
Share on other sites

Thank you so much @Guest works perfect.

After this invasion of fake messages and account creation I have installed a reCaptcha and few more security layers.

really don't imagine a few lines of code made such a big work on background, you are really good developer.

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...