Droip Ecommerce Documentation

website·Indexed 30 days ago

https://droip-ecommerce-docs.vercel.app/docs/getting-started/installation

Developer documentation for the Droip Ecommerce WordPress plugin, featuring a custom Laravel-inspired framework for PHP 7.4+. Includes guides on the request lifecycle, service container, routing, middleware, and a database layer with a fluent Query Builder, migrations, and seeding.

Tokens
27.3K
Snippets
213
Records
235
Agent score
75%

What's inside Droip Ecommerce

  1. Overview of the Query Builder

    The Ecommerce\Core\Database\Query\QueryBuilder class provides a fluent, chainable API for creating and running database queries. It is accessed through Model classes (e.g., Product::where()), allowing developers to build optimized SQL statements without writing raw SQL.
  2. Overview of the Collection class

    The Ecommerce\Core\Collections\Collection class is a fluent wrapper around arrays of data. It is used extensively by the Query Builder to return results and allows developers to chain methods for filtering, mapping, and transforming data. All Query Builder methods that retrieve multiple records return an instance of this class.
  3. Droip Ecommerce Layered Architecture

    The application follows a layered architecture pattern to separate concerns between data access, business logic, and the HTTP layer.

    Architecture Layers

    1. Models: Eloquent-style ORM models for DB interaction (e.g., Product, Order, Customer).
    2. Services: Business logic layer (e.g., ProductService, OrderService, PaymentGatewayService).
    3. Repositories: Data access layer abstracting DB operations (e.g., ProductRepository, OrderRepository).
    4. Controllers: RESTful API controllers in app/Http/Controllers/Api/ handling requests and responses.
    5. DTOs: Data Transfer Objects for type-safe data passing between layers.
    6. Actions: Single-responsibility classes for specific operations.
    7. Decisions: Business rule engine consisting of Conditions and Actions.
    8. Resources: API response transformers for consistent JSON output.
  4. Implement data validation for ecommerce structures

    Use the built-in validation library to ensure data integrity. The library supports nested structures, wildcards, and custom rules specifically tailored for ecommerce requirements.
  5. Droip Ecommerce Framework Overview

    Droip Ecommerce is a WordPress plugin built on a custom Laravel-inspired framework using PHP 7.4+. It implements a Clean Architecture with a Repository-Service-Controller pattern and utilizes a custom dependency injection container with autowiring. Key features include a custom migration system (38 tables), a RESTful API with 200+ endpoints, and an extensible payment gateway system (including Stripe).
  6. Droip Ecommerce Database Schema Overview

    The system manages 38 database tables via a migration system. The schema is divided into several functional domains:

    Core Tables

    • Product Management: products, variants, product_schemas, brands, categories, tags, collections, attributes, attribute_values
    • Order Management: orders, order_items, order_activities, refunds
    • Cart Management: carts, cart_items
    • Customer Management: customers, addresses
    • Pricing & Promotions: coupons, coupon_usage, currencies
    • Shipping & Tax: shipping_profiles, shipping_boxes, tax_profiles
    • Localization: languages, product_translations, collection_translations, attribute_translations
    • System: scheduler_jobs
  7. Define REST API routes using the Route class

    The Ecommerce\Core\Route class provides a static, fluent interface for registering HTTP endpoints. It maps URI patterns to controller methods and allows for request filtering via middleware and organization via route groups.
  8. Understand the Droip Ecommerce project directory structure

    The Droip Ecommerce framework uses a modular architecture inspired by Laravel, adapted for WordPress. The project is organized into a clear separation between application business logic (backend/App) and framework infrastructure (backend/Core).
    Ecommerce
    ├── backend                 # Core backend application code
    │   ├── App                 # Application domain logic
    │   │   ├── Constants       # Application constants
    │   │   ├── Contracts       # Interfaces and Contracts
    │   │   ├── DTO             # Data Transfer Objects
    │   │   ├── Exceptions      # Custom Exceptions
    │   │   ├── Hooks           # WordPress Action/Filter Hooks
    │   │   ├── Http            # Controllers, Middlewares, Requests
    │   │   ├── Models          # Eloquent Models
    │   │   ├── Providers       # Service Providers
    │   │   └── Services        # Business Logic Services
    │   ├── Core                # Framework Core Components
    │   │   ├── Console         # CLI Commands
    │   │   ├── Database        # Database migrations, seeders, schema
    │   │   ├── Managers        # Core Managers (Option, Log, etc.)
    │   │   └── ...
    │   └── ...
    ├── bootstrap               # Bootstrapping scripts
    │   ├── app.php             # Main application bootstrapper
    │   └── providers.php       # Provider registration
    ├── configs                 # Configuration files
    ├── resources               # Frontend resources
    │   └── views               # Blade/PHP templates
    ├── routes                  # Application routes
    │   └── api.php             # API route definitions
    ├── src                     # Frontend source code (React/Vue/JS)
    ├── composer.json           # PHP dependencies
    └── index.php               # Plugin entry point
  9. Manage data with the Flex container

    The Flex class is a versatile data container that implements ArrayAccess and supports magic property access. It allows for flexible reading and writing of attributes.
    $data = new Flex(['theme' => 'dark']);
    
    // Get value (method, property, or array access)
    echo $data->get('theme'); // 'dark'
    echo $data->theme;       // 'dark'
    echo $data['theme'];      // 'dark'
    
    // Set value (fluent method, property, or array access)
    $data->set('name', 'Product')->set('price', 100);
    $data->description = 'Sample';
    $data['active'] = true;
    
    // Check existence
    if ($data->exists('theme')) {
        // ...
    }
    
    // Convert to array
    $array = $data->to_array();
  10. Understand the core architecture and request lifecycle

    The system is built on a modular and extensible architecture designed for scalability and seamless WordPress integration. Key architectural components include the Service Container, Facades, and a defined Request Lifecycle.
  11. Record log messages using the Log facade

    The Ecommerce\Supports\Facades\Log facade provides a static interface to the LogManager for recording messages to a log file. By default, logs are written to the droip-ecommerce.log file located in the wp-content directory.