Duplicate guest accounts

Hi,

Does anyone know how to prevent (or more likely merge) duplicate quest accounts based on the same email address, after a customer places an order without registering and does this over time?

We don’t want to disable the option for the customer to place an order without registration. But multiple guest account of the same customer would pollute our database.

Hopefully someone else encountered the same problem and found a solution. Many thnx!

Hi Joris,

Did you ever found a solution for this. We are looking at the same issue here. Some guests have 20+ ‚customer‘ accounts.

BTW there is an option in Settings → Log-in & signup called:

Expiry time of guest customer accounts

Standard is 86400 second which is 24 hours.

But that does not prevent the auto-increment of the customer numbers though.

You can find more information here:

However I’ve set it to 10 seconds and ran the command, but it claims that there are no unused guest accounts, so nothing is deleted. Probably because they don’t consider guest unused if they have placed an order. The code has to be altered to delete all guest accounts I think.

This query can be tested in your environment. It works for customers that are bound to a sales channel:

UPDATE order_customer oc
INNER JOIN (
    SELECT c1.id AS customer_id, c1.email, c1.bound_sales_channel_id, c1.customer_number, oc.order_id, (
        SELECT MIN(c2.id)
        FROM customer c2
        WHERE c2.email = c1.email
    ) AS oldest_customer_id
    FROM customer c1
    INNER JOIN order_customer oc ON c1.id = oc.customer_id
    WHERE c1.guest = 1
    AND (
        SELECT COUNT(*)
        FROM customer c2
        WHERE c2.email = c1.email
        AND c2.bound_sales_channel_id = c1.bound_sales_channel_id
        AND c2.customer_number < c1.customer_number
    ) > 0
) AS customer_data ON oc.customer_id = customer_data.customer_id
SET oc.customer_id = customer_data.oldest_customer_id;

It moves guest orders to the oldest guest account available. Achter this the other guests accounts are empty and can be deleted with the ‚Unused Guests‘ CLI.