GPLv3 & OpenCart: Our GDPR Fixes Are Submitted

Below is the full description of our pull request to OpenCart, exactly as submitted: https://github.com/opencart/opencart/pull/15810

Add an immediate account-removal option for GDPR requests, and fix four GDPR bugs

Summary

This adds an opt-in setting, GDPR Immediate Removal (config_gdpr_remove_immediate), so a store can delete a customer account as soon as an admin approves a confirmed removal request, instead of waiting for the GDPR cron.

It also fixes four bugs in the existing GDPR flow. The new setting is off by default, so stores that leave it off keep the stock approval-and-wait behaviour, plus the bug fixes.

Motivation

GDPR Article 17 gives a person the right to erasure. Article 12(3) says the controller must act without undue delay and at the latest within one month. Article 17(3)(e) still allows keeping data that is needed for the establishment, exercise or defence of legal claims, such as recent orders needed for fraud checks, chargebacks and refunds.

Customers who ask for their account to be deleted expect it to happen now, not months later. In stock OpenCart the admin approval only marks a removal request as “processing”; the account stays until the GDPR cron runs after config_gdpr_limit days (180 by default). That delay is longer than most customers expect, and longer than “without undue delay” for the account itself.

This change lets a store owner turn on immediate deletion of the account at approval, while still keeping recent orders and returns in a minimised form until the configured limit, which is a reasonable legal-claims basis (Articles 17(3)(e), 5(1)(c) and 5(1)(e)).

New setting: config_gdpr_remove_immediate

  • Default: off (0). Fresh installs get the row from the install SQL. On an upgraded store the setting is off until Settings are saved.
  • Admin: System > Settings > Option tab, next to the existing GDPR Limit, with a switch and help text: “Delete the customer account as soon as a removal request is approved. Orders and returns inside the GDPR limit are kept in minimised form for fraud detection, chargebacks and refunds, then anonymised by the GDPR cron once the limit has passed.”

When the setting is on, and an admin clicks Approve on a removal request that the customer has already confirmed (status 1, pending) or that is already processing (status 2):

  1. The request is set to complete (3) if nothing needs to be kept, or processing (2) if recent orders or returns are still inside the GDPR limit. The status is updated first so the customer mail can still greet them by name.
  2. The customer account is deleted immediately with the usual customer delete, plus related data the stock delete does not cover (cart, online and search logs, tokens, affiliate report, reviews, article comments and ratings, failed-login rows, coupon history detached). Active subscriptions are set to the cancelled status and detached. Logged-in sessions end because the customer row is gone.
  3. Orders and returns older than config_gdpr_limit, and missing orders (status 0), are anonymised at once (personal fields blanked; amounts, products, tax, country, zone and dates kept). Orders and returns still inside the limit are minimised (customer id, telephone, custom fields, address ids and accept-language cleared; name, e-mail, billing and shipping address, IP, user agent, products, totals and payment method kept) and held for fraud checks, chargebacks and refunds.
  4. The customer is e-mailed. If the request is complete, they get the stock “request has been processed” mail. If records are being kept, they get the approval mail, which now says the account has been deleted and that the kept records will be anonymised within N days, with a contact link for disputes.
  5. The GDPR cron later anonymises each kept record once it has passed the limit, then sets the request to complete (3) and sends the completion mail. If the account is somehow still there, the cron deletes it too.

Unverified (0), complete (3) and denied (-1) removal requests are not processed by Approve when the setting is on.

When the setting is off, Approve still only marks a removal as processing (2). The cron then waits until config_gdpr_limit days after the request was added (with the expiry-date bug fixed) and deletes the account the stock way.

Four stock bug fixes

These apply whether the new setting is on or off.

1. editStatus() stored “complete” as “pending”

Before: catalog/model/account/gdpr.php editStatus() cast the status to (bool). When the cron set a request to complete (3), MySQL stored 1 (pending). -1 (denied) would also have become 1. The admin list then showed the request as pending again. The completion mail still went out, because the mail event used the method argument, not the value in the database.

After: The status is stored as (int)$status, so 3 stays 3 and -1 stays -1.

2. getExpires() compared the date the wrong way

Before: getExpires() (catalog model, and the unused copy in the admin model) selected processing requests where date_added was less than or equal to today plus the GDPR limit. Every processing request therefore matched on the next cron run, so stock actually deleted the account about a day after approval (if the cron ran), not after 180 days.

After: The comparison uses today minus the limit, so a processing request is only due once config_gdpr_limit days have passed.

3. The removal-approval mail never fired

Before: The admin mail hook sent the “approved” mail only when $gdpr_info['action'] == 'approve' and the new status was 2. A removal request’s action is 'remove', never 'approve', so that mail was never sent.

After: The condition is action == 'remove' and status 2, which is the real approval case. The mail text is also updated when immediate removal is on, so it describes an account that has already been deleted.

4. A second request was silently ignored, but the page still said “success”

Before: catalog/controller/information/gdpr.php action() looked up existing GDPR rows for the e-mail. If any row already had the same action, in any status (including complete or denied), it skipped addGdpr(). It still returned text_success (“An email has been sent to your email address!”). No new row was created and no confirmation e-mail was sent, so the customer was told to check their inbox for a message that never arrived. A completed or denied request also blocked a later genuine request.

After: A request is treated as a duplicate only if one for the same e-mail and action is still open:

  • Unverified (status 0): the confirmation e-mail is sent again for the existing code (same confirmation link). The response is text_exists, which tells the customer to check their e-mail, including the spam folder. No second row is added.
  • Pending or processing (status 1 or 2): the response is error_exists (“A request is already pending…”). No e-mail is sent and no row is added.
  • Complete (3) or denied (-1): a new request is created and the confirmation e-mail is sent, as for a first request.

An open remove request does not block a new export, and the other way around, as before.

Admin alert when the customer confirms

This branch does not add the optional admin mail alert that fires when a customer confirms a request (status changes to 1). That is a separate, also opt-in change; see the fix/gdpr-admin-mail-alert package. The two changes work together: the customer must confirm by e-mail, the store can be told at once, and Approve can then delete the account immediately if this setting is on.

Storefront wording

When immediate removal is on, the GDPR request page and the confirmation success page say that the account will be deleted immediately once the request is approved, that it may take up to the configured number of days if fraud, chargebacks or refunds still need to be processed, and that the customer should contact the store about disputes.

When the setting is off, the stock “processed after N days” wording is unchanged.

The new text_exists and error_exists strings cover the duplicate-request cases above.

Testing

Integration tests run against a real OpenCart 4.1 install (models, controllers, events, Twig and MariaDB). Mail is captured by a spy mail engine; nothing is sent out.

  • Patched 4.1.x.x: 48 passed, 0 failed.
  • The same tests on unpatched origin/4.1.x.x: 15 passed, 33 failed, which shows that the tests catch the missing feature and all four stock bugs.

php -l, php-cs-fixer (project config, dry-run) and phpstan on the changed controller and model files are clean.

There was also a live end-to-end test on a production OpenCart 4.1.0.5 store on 20 November 2026: request removal → confirmation e-mail → admin alert e-mail “Confirmed GDPR Account Removal Request” → Approve → the customer disappeared from Admin > Customers immediately. (The admin alert came from the separate mail-alert change mentioned above.)

Known limitations

These are existing stock gaps and are not changed here:

  • Order history comments, return history comments, order option values and uploaded files are not anonymised.
  • Payment-gateway subscription tokens are not cancelled; only the OpenCart subscription row is set to cancelled and detached. The store still needs to cancel the billing token with the gateway if there is one.
  • Store credit (customer transactions) is deleted with the account and is not paid out automatically.
  • Guest orders placed under a different e-mail address are not matched to the request.
  • After the GDPR limit, orders are anonymised (name and address removed, amounts, tax, country and zone kept). Some tax or accounting rules require the buyer’s name and address to be kept for longer than config_gdpr_limit. That is a policy decision for the store; a longer invoice-retention option is not part of this change.
  • Delayed anonymisation of records kept inside the limit still depends on the OpenCart GDPR cron actually running (daily is enough). If the cron is not running, those minimised records stay until it does.

Approval itself is still a manual admin step. The code does not enforce the one-month deadline in Article 12(3).

Backward compatibility

The new setting is off by default. With it off, approval, cron timing and customer deletion follow the stock flow, except for the four bug fixes: complete status is stored correctly, the cron waits for the configured limit instead of running the next day, the removal-approval mail is actually sent, and a second request is no longer silently dropped with a false success message.

No database schema changes. No existing GDPR rows are rewritten.

References