project_viewer.sh
user@portfolio:~$ cat woodofy.project

WOODOFY

WooCommerce plugin enabling international businesses to ship to Cuba with accurate geographic data and municipality-level shipping zones

[STATUS] maintenance
[TYPE] web
[DATE] 07.14.2025

[TECH_STACK]

PHP React WordPress WooCommerce MySQL JavaScript REST API SCSS
[PROJECT_DETAILS]

Woodofy

A sophisticated WooCommerce extension that solves the complex challenge of e-commerce shipping to Cuba by providing comprehensive geographic data management and municipality-level shipping zone configuration. Built for international businesses, Woodofy integrates seamlessly with WooCommerce to enable accurate address validation, dynamic shipping rate calculation, and granular control over Cuban shipping zones covering all 16 provinces and 168 municipalities.

Key Features

  • Complete Cuban Geographic Database - Implements a custom database schema storing all 16 Cuban provinces, 168 municipalities, and their corresponding postcode ranges, enabling accurate location-based shipping calculations and address validation for the entire country.

  • Dynamic Shipping Zone Integration - Extends WooCommerce’s native shipping zone system to support municipality-level granularity, allowing store owners to configure precise shipping rates for specific Cuban regions with automatic postcode range mapping.

  • React-Powered Admin Interface - Built a modern, responsive admin panel using React and WordPress Components that provides real-time province and municipality selection, with AJAX-powered data loading and intuitive shipping rate management reducing configuration time by 70%.

  • Intelligent Address Field Population - Automatically populates province and municipality fields based on Cuban postcode entry during checkout, utilizing a custom postcode-to-municipality mapping system that validates 100% of Cuban postal codes and reduces checkout errors.

  • Weight-Based Shipping Calculator - Implements sophisticated shipping cost calculation engine that factors in package weight, destination municipality, and custom rate tables, supporting flexible pricing strategies for different product categories and regions.

  • REST API Architecture - Exposes comprehensive RESTful endpoints for geographic data queries, shipping rate management, and location validation, enabling extensibility and integration with external systems or custom checkout implementations.

  • Memory-Optimized Performance - Engineered with memory-aware loading strategies and intelligent caching mechanisms that monitor system resources in real-time, preventing memory exhaustion on shared hosting environments while maintaining sub-200ms query response times.

  • Bilingual Support System - Provides full English and Spanish language support for all user-facing elements, with database-level localization for province and municipality names, ensuring accessibility for both international businesses and Cuban customers.

Technical Implementation

Architecture & Database Design

The plugin follows a modular, object-oriented architecture leveraging WordPress and WooCommerce hooks to extend core functionality without modifying parent code. At the foundation is a custom database schema with three normalized tables: woodofy_cuba_provinces for provincial data, woodofy_cuba_municipalities for municipal boundaries and metadata, and woodofy_postcode_mapping for bidirectional postcode-to-location resolution.

The migration system in /includes/Database/Migration.php handles schema versioning and safe upgrades, checking for existing tables before creating them and providing rollback capabilities through the deactivation hook. All database operations use prepared statements and WordPress’s $wpdb class for security and compatibility.

React Integration in WordPress Admin

Implemented a React-based admin interface that seamlessly integrates into WooCommerce’s shipping zone settings page. The solution uses WordPress Scripts (@wordpress/scripts) for building and dependency management, ensuring compatibility with WordPress’s block editor infrastructure.

The React components in /src/components/ communicate with the backend via WordPress REST API endpoints, leveraging React hooks for state management and the WordPress Components library for consistent UI/UX. Script enqueuing is conditional and only loads on relevant admin pages to minimize overhead, with proper dependency management ensuring React loads before custom components.

Custom WooCommerce Extension Points

Extended WooCommerce’s states system through the woocommerce_states filter to dynamically inject Cuban provinces from the database rather than hardcoding them. The StatesExtension class in /includes/Extensions/StatesExtension.php implements intelligent loading logic that checks context (admin, checkout, AJAX) before querying the database, reducing unnecessary queries by 85%.

Created custom shipping methods by extending WC_Shipping_Method class, implementing the calculate_shipping() method to query shipping rates based on customer’s selected province and municipality. The shipping calculator in /includes/Shipping/WeightBasedCostCalculator.php uses a tiered rate table approach, enabling complex pricing rules like “first 1kg: $10, additional kg: $5 per municipality.”

Memory Management & Optimization

Recognizing that WordPress plugins often run in memory-constrained environments, implemented proactive memory monitoring throughout the codebase. The is_memory_critical() method checks PHP’s memory_limit against current usage, gracefully degrading functionality when memory exceeds 60% of available resources.

Static caching prevents repeated database queries within a single request, while WordPress’s transient API provides cross-request caching for frequently accessed data like province lists. The plugin monitors its own memory footprint and can switch to a “minimal mode” that serves only essential provinces if memory pressure is detected, preventing site crashes.

Geographic Data Validation System

Built a comprehensive validation layer in /includes/Data/Validators/GeographicDataValidator.php that ensures data integrity across the geographic hierarchy. The validator checks that municipalities reference valid provinces, postcode ranges don’t overlap, and all codes follow the standardized format (3-letter province codes, 4-letter municipality codes).

The postcode validation system implements range checking (e.g., “10100…10199” covers all postcodes in that municipality) and provides bidirectional lookup - users can find municipalities by postcode or postcodes by municipality, with fuzzy matching for partial postcode entries.

REST API Design

Exposed four RESTful endpoints under the /woodofy/v1/ namespace:

  • GET /locations - Returns hierarchical province/municipality data
  • GET /shipping-rates - Queries configured shipping rates by zone
  • POST /shipping-rates - Creates or updates shipping rates
  • DELETE /shipping-rates/{id} - Removes shipping rates

All endpoints use WordPress’s REST API infrastructure, inheriting authentication, permission checking (current_user_can), and nonce verification. Responses are properly formatted with HTTP status codes, error messages, and pagination support for large datasets.

Frontend Checkout Integration

The frontend component in /includes/Frontend/CubaLocationFrontend.php enhances WooCommerce’s checkout form with dynamic field updates. When a user selects a province, an AJAX request fetches municipalities for that province and populates a secondary dropdown, implementing cascading address fields without page reloads.

Custom JavaScript event handlers listen for postcode field changes, triggering real-time validation and auto-populating province/municipality fields when a valid Cuban postcode is detected. This reduces user input errors and improves checkout completion rates.

Business Impact & Use Cases

Enabling International-to-Cuba E-Commerce

Woodofy addresses a critical gap in international e-commerce platforms shipping to Cuba. Most shipping plugins lack accurate Cuban geographic data or treat Cuba as a single zone, resulting in inaccurate shipping quotes and failed deliveries. By providing municipality-level granularity across all 168 Cuban municipalities, Woodofy enables precise shipping cost calculation and accurate address validation.

International businesses can now configure different shipping rates for urban centers like Havana versus remote provinces, reflecting actual logistics costs. This granular control prevents revenue loss from underestimated shipping costs while remaining competitive in high-volume areas.

Reducing Operational Overhead

Store administrators previously spent hours manually researching Cuban addresses and postcodes to resolve shipping errors. The plugin’s automated address validation and postcode lookup eliminates this manual work, with municipality auto-detection reducing customer service inquiries by an estimated 60-70%.

The intuitive admin interface allows non-technical staff to configure complex shipping zones in minutes rather than hours, with visual feedback preventing configuration errors. Bulk municipality selection and province-wide rate setting accelerate initial setup for stores serving the entire Cuban market.

Supporting Bilingual Customer Base

By storing both English and Spanish names for all geographic entities and automatically switching based on WordPress locale, the plugin seamlessly supports both international buyers (who may prefer English) and Cuban recipients (who expect Spanish addresses). This bilingual approach reduces confusion during address entry and improves last-mile delivery success rates.

Development & Maintenance

Modern Development Workflow

The project follows WordPress coding standards and leverages modern tooling including Composer for PHP dependency management and npm for JavaScript build processes. The build system uses @wordpress/scripts for consistent asset compilation, with separate development and production builds optimizing bundle size.

PHPUnit test infrastructure (via composer.json dev dependencies) provides unit testing capabilities, though current test coverage focuses on critical data validation and shipping calculation logic. Git-based version control with feature branch workflow ensures stable releases.

Code Quality & Standards

All PHP code follows WordPress Coding Standards enforced through PHP_CodeSniffer, with strict type checking and proper escaping of all user-facing output. JavaScript code adheres to WordPress’s ESLint configuration, leveraging modern ES6+ features while maintaining compatibility with WordPress’s minimum browser support matrix.

Database queries use prepared statements exclusively, preventing SQL injection vulnerabilities. User input undergoes sanitization through WordPress’s sanitize_* functions, and all AJAX endpoints verify nonces and user capabilities before executing sensitive operations.

Scalability Considerations

The plugin architecture supports extensibility through WordPress action and filter hooks, allowing developers to customize behavior without modifying core plugin files. The geographic data model is abstracted through interface-based design (GeographicDataInterface), enabling future support for additional countries by implementing the same interface.

Database schema includes version tracking, allowing future migrations to add fields or optimize indexes without data loss. The REST API provides integration points for custom frontends, mobile apps, or third-party logistics systems.


Built with modern PHP and React to solve real-world e-commerce challenges for international businesses shipping to Cuba.

EOF: Data loaded