Skip to content

replantadev/dniwoo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DNIWOO - DNI/NIF for WooCommerce

Professional DNI/NIF field for WooCommerce checkout with validation for Spain and Portugal.

Features

  • Professional validation for Spanish documents (DNI, NIE, CIF)
  • Portuguese document support (NIF, NIPC)
  • Real-time validation with AJAX
  • Client-side validation for instant feedback
  • WooCommerce integration - seamless checkout experience
  • HPOS compatible - works with WooCommerce High Performance Order Storage
  • Theme compatibility - works with all major themes
  • Responsive design - mobile-friendly
  • Accessibility - WCAG compliant
  • Auto-updates via GitHub
  • WordPress standards compliant

Installation

IMPORTANT: Download from Releases, not the "Code" button.

Method 1: WordPress Admin (Recommended)

  1. Go to GitHub Releases
  2. Download the latest dniwoo-vX.X.X.zip file
  3. In WordPress: Plugins > Add New > Upload Plugin
  4. Upload the ZIP file and activate

Method 2: Manual Installation

  1. Download from Releases
  2. Extract the ZIP file
  3. Upload the dniwoo folder to /wp-content/plugins/
  4. Activate in WordPress admin

⚠️ Do NOT download from "Code" button

This creates folder naming issues. Always use the Releases section.

Requirements

  • WordPress 5.0 or higher
  • WooCommerce 7.0 or higher
  • PHP 7.4 or higher

Configuration

Navigate to WooCommerce > Settings > DNIWOO to configure:

  • Enable/Disable the DNI field
  • Required field - make DNI mandatory
  • Validation mode - real-time or on submit
  • Error messages - customize validation messages
  • Field position - choose where to display the field
  • Country detection - automatic field type switching

Supported Documents

Spain

  • DNI (Documento Nacional de Identidad) - 8 digits + letter
  • NIE (Número de Identidad de Extranjero) - X/Y/Z + 7 digits + letter
  • CIF (Código de Identificación Fiscal) - Letter + 7 digits + control

Portugal

  • NIF (Número de Identificação Fiscal) - 9 digits
  • NIPC (Número de Identificação de Pessoa Coletiva) - 9 digits

Field Validation

Client-side (JavaScript)

  • Format validation while typing
  • Real-time AJAX validation (optional)
  • Immediate user feedback
  • Prevents form submission with invalid data

Server-side (PHP)

  • Complete validation algorithms
  • Double-check on form submission
  • Security against tampering

Theme Compatibility

DNIWOO is designed to work with all WordPress themes:

  • Astra
  • Storefront
  • GeneratePress
  • OceanWP
  • Divi
  • Avada
  • And many more

Styling

The plugin includes comprehensive CSS that adapts to your theme:

  • Responsive design for all devices
  • Dark mode support
  • High contrast mode support
  • RTL (right-to-left) language support
  • Print-friendly styles

Hooks & Filters

Actions

// Before validation
do_action('dniwoo_before_validation', $document, $country);

// After validation
do_action('dniwoo_after_validation', $document, $country, $is_valid);

// Field output
do_action('dniwoo_before_field');
do_action('dniwoo_after_field');

Filters

// Modify field settings
$settings = apply_filters('dniwoo_field_settings', $settings);

// Customize validation
$is_valid = apply_filters('dniwoo_validate_document', $is_valid, $document, $country);

// Custom error messages
$message = apply_filters('dniwoo_error_message', $message, $document, $country);

// Field position
$position = apply_filters('dniwoo_field_position', $position);

JavaScript API

// Get validation status
const isValid = DNIWOOCheckout.isValidDocument('12345678A');

// Validate specific country
const isValidSpain = DNIWOOCheckout.validateSpain('12345678A');
const isValidPortugal = DNIWOOCheckout.validatePortugal('123456789');

// Manual validation trigger
DNIWOOCheckout.validateField($('#billing_dni'));

REST API

Validate Document

Endpoint: POST /wp-json/dniwoo/v1/validate

Parameters:

  • document (string) - Document to validate
  • country (string) - Country code (ES/PT)

Response:

{
  "valid": true,
  "message": "Valid document",
  "document_type": "DNI",
  "formatted": "12345678-A"
}

Troubleshooting

Plugin not working?

  1. Check WooCommerce - Ensure WooCommerce is active and updated
  2. Clear cache - Clear any caching plugins
  3. Theme conflicts - Test with a default theme
  4. Plugin conflicts - Deactivate other plugins temporarily
  5. PHP version - Ensure PHP 7.4 or higher

Field not showing?

  1. Check if the field is enabled in settings
  2. Verify the field position setting
  3. Ensure the checkout page is using WooCommerce shortcodes
  4. Check for theme customizations that might hide fields

Validation not working?

  1. Test with known valid documents:
    • Spain: 12345678Z
    • Portugal: 123456789
  2. Check browser console for JavaScript errors
  3. Verify AJAX URL is working
  4. Test server-side validation independently

Development

Local Development

# Clone repository
git clone https://github.com/replantadev/dniwoo.git

# Install dependencies (if any)
cd dniwoo
composer install --dev

# Run tests
composer test

Coding Standards

This plugin follows WordPress coding standards:

# Check coding standards
composer phpcs

# Fix coding standards
composer phpcbf

Security

Validation Security

  • All inputs are sanitized
  • Server-side validation as final check
  • CSRF protection with nonces
  • XSS prevention with proper escaping

Data Privacy

  • No personal data stored by default
  • GDPR compliant
  • No external API calls for validation
  • Local validation algorithms

Performance

  • Lightweight - Minimal footprint
  • Conditional loading - Assets only on checkout
  • Optimized CSS - Minimal styles, theme-adaptive
  • Efficient JS - ES5 compatible, no dependencies

Changelog

1.1.0 (2026-02-28)

  • Added full HPOS (High Performance Order Storage) compatibility
  • Support for WooCommerce custom order tables
  • Updated to use WooCommerce Order API
  • Minimum WooCommerce version now 7.0
  • Tested with WordPress 6.7 and WooCommerce 9.6

1.0.7 (2026-02-03)

  • Fixed Portugal validation country code case sensitivity
  • Fixed JavaScript error with Portugal messages

1.0.0 (2024-01-XX)

  • Initial release
  • Spain and Portugal support
  • Real-time validation
  • Professional WordPress standards
  • Auto-update system
  • Complete documentation

Support

License

GPL v3 or later - License

Credits

Developed by Replanta - Sustainable WordPress solutions.

About

Añade DNI/NIE/CIF/NIF/NIPC para españa y portugal a Woocommerce

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors