Jump to content

[FREE MODULE] Customer DNI - New field for customer to enter a custom identifier


ebiggio

Recommended Posts

Hello everyone!

For a recent project, I needed a way to store and manage a unique customer identifier besides the standard email address. In my country (Chile), all the people have an ID called “RUT” (Rol Único Tributario) which, in the case of my project, is used to validate the customer’s identity to apply specific discounts and benefits. While PrestaShop already handles a field that could be used to store this identifier, it operates at the address level. This means that a customer can have multiple addresses with different DNIs, and its value can even be shared between different customers. So I decided to create a module with all the necessary validations and integrations to make it work seamlessly with the rest of the platform.

This module is called “Customer DNI.” The reason I named it “DNI” is that it’s a common term used in many countries to refer to a unique identifier for citizens. This module creates a new field at the customer level, with several options to configure its behavior:

  • Validation options: Set the DNI as required, unique, and even validate it with a custom regular expression.
  • Back office integration: View and edit the customer’s DNI directly from the customer list, where you can also filter and sort by this field.
  • Address syncing: Optionally overwrite all existing address DNI fields whenever the customer’s DNI is updated. Very useful if you want to handle the DNI at the customer level, but still need to operate with the address DNI (for example, to generate invoices).
  • Custom validators: Easily add your own validation logic with a custom PHP class (a Chilean RUT validator is already included as an example).
  • Custom hooks for developers: Trigger custom actions whenever a DNI is saved or deleted, allowing deeper integrations with your own modules.
  • Multilanguage support: Translate the DNI field label and validation messages to any language available in your shop.
  • No core modifications: The module is built following PrestaShop’s best practices, so it doesn’t modify any core files. It also does not perform any overrides or change the default database schema, other than creating a new table to store the DNI value along with the customer ID.

The module is available for free on GitHub, with a README file that explains in more detail its features and how to install it: https://github.com/ebiggio/prestashop-customer-dni

Requirements:

  • PrestaShop 8.0 or higher (should work on versions 1.7.7 and higher, but I haven’t tested it).
  • PHP 8.0 or higher.

Some screenshots of how the module operates:

imagen.png.74d457875ffe2e5f2550fade3ac100b2.png

Module settings.

imagen.thumb.png.a222b892dd172804ae2617e77486b9f0.png

Customer's personal information form.

imagen.thumb.png.a385c09ef84b2295d2cd783fcbf6295f.png

Back office customer list.

imagen.thumb.png.bdda909ce7fe173f45064e9b4a65f21a.png

Back office customer edit form.

If you have any questions or suggestions, please let me know. Thanks, and happy selling!

customer_dni-v1.1.2.zipFetching info...

Edited by ebiggio
Added screenshots of module operation (see edit history)
Link to comment
Share on other sites

  • 2 weeks later...

Hello Hadi!

No problem whatsoever. Customers that registered before the installation and activation of this module will be able to login and continue shopping without any issues. Only if the customer later wants to change their personal info will the new field be presented to them, where the module will handle its processing according to the configuration.

  • Like 1
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...