WP Manifestindependent plugin directory
manifest / ecommerce / invoicenow-wordpress-plugin

Invoice Now for WooCommerce

Seamless WooCommerce integration for Invoice Now invoicing platform. Automatically create and sync invoices from WooCommerce orders.

by Invoice Now · github.com/adetech2017/invoicenow-wordpress-plugin · website

0stars
0forks

Install

No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:

wp plugin install https://github.com/adetech2017/invoicenow-wordpress-plugin/archive/refs/heads/main.zip

A seamless WordPress/WooCommerce integration for Invoice Now - the modern invoicing SaaS platform. This plugin connects your WooCommerce store with Invoice Now backend, enabling automatic invoice creation, synchronization, and management directly from your WordPress admin.

Features

  • Automatic Invoice Creation - Automatically generate invoices when WooCommerce orders are placed
  • Order Status Sync - Keep invoice statuses in sync with WooCommerce order statuses
  • Manual Invoice Creation - Create invoices manually for existing orders from the admin
  • Admin Settings Page - Simple configuration interface for API credentials
  • Shortcodes - Display invoices and invoice lists on the frontend
  • WooCommerce Integration - Seamless integration with WooCommerce orders
  • API Key Authentication - Secure communication with Invoice Now backend
  • Multi-Tenant Support - Support for multiple Invoice Now tenants

Prerequisites

  • WordPress 5.0 or higher
  • WooCommerce 3.0 or higher
  • PHP 7.4 or higher
  • Node.js & NPM (for development)
  • Composer (for PHP dependencies)
  • Invoice Now account with API credentials

Installation

1. Upload Plugin Files

# Clone or download the plugin to your WordPress plugins directory
cd /path/to/wordpress/wp-content/plugins/
git clone https://github.com/yourusername/invoicenow-wordpress-plugin.git
cd invoicenow-wordpress-plugin

2. Install Dependencies

# Install PHP dependencies
composer install

# Install Node dependencies (if developing)
npm install

# Build assets (if developing)
npm run build

3. Activate Plugin

  1. Go to WordPress AdminPlugins
  2. Find "Invoice Now WordPress Plugin"
  3. Click Activate

4. Configure API Settings

  1. Go to WooCommerceInvoice Now Settings
  2. Enter your Invoice Now API credentials:
    • API URL: Your Invoice Now backend URL (e.g., http://127.0.0.1:8082)
    • API Key: Your Invoice Now API key from Developer Settings
    • Tenant ID: Your Invoice Now tenant ID
    • Enable WooCommerce Sync: Check to automatically create invoices from orders
  3. Click Test Connection to verify settings
  4. Save changes

Configuration

Getting Your API Credentials

  1. Log in to your Invoice Now dashboard
  2. Go to SettingsDeveloperAPI Keys
  3. Create a new API key (or use existing)
  4. Copy the:
    • API Base URL
    • API Key
    • Tenant ID

API URL Format

The plugin automatically appends /api/v1 to your base URL, so provide:

  • Development: http://127.0.0.1:8082
  • Production: https://api.yourdomain.com

Enabling WooCommerce Sync

Check "Enable WooCommerce Sync" to automatically:

  • Create invoices when orders are placed
  • Update invoice status when order status changes
  • Store the invoice ID in order metadata

Usage

Admin Dashboard

Viewing Invoice Now Dashboard

  1. Go to WooCommerceInvoice Now Settings
  2. Browse invoices and manage sync settings
  3. Manually create invoices for existing orders

Manual Invoice Creation

From the order edit page:

  1. Open any WooCommerce order
  2. Look for the Invoice Now section
  3. Click Create Invoice if no invoice exists
  4. Invoice will be created and linked to the order

Frontend Shortcodes

Display Single Invoice

[invoicenow_invoice id="invoice-uuid"]

Displays a formatted invoice with customer info, items, and totals.

Display Order Invoice

[invoicenow_order_invoice order_id="123"]

Displays the invoice associated with a WooCommerce order. If order_id is omitted, it uses the query parameter ?order_id=123.

Example on customer dashboard:

[invoicenow_order_invoice]

Display Invoices List

[invoicenow_invoices_list limit="10" status="SENT"]

Displays a table of invoices for the logged-in user.

Attributes:

  • limit: Number of invoices to display (default: 10)
  • status: Filter by invoice status (e.g., "DRAFT", "SENT", "PAID", "CANCELLED")

Example:

[invoicenow_invoices_list limit="20"]
[invoicenow_invoices_list limit="10" status="PAID"]

Architecture

Directory Structure

invoicenow-wordpress-plugin/
├── invoicenow-wordpress-plugin.php     # Plugin entry point
├── includes/
│   ├── Admin/
│   │   ├── Settings.php               # Settings page & API config
│   │   └── Setup.php                  # Plugin initialization
│   ├── Client/
│   │   └── FastAPIClient.php          # API client wrapper
│   ├── Services/
│   │   └── InvoiceService.php         # Business logic
│   ├── Integrations/
│   │   └── WooCommerceIntegration.php # WooCommerce hooks
│   └── Frontend/
│       └── Shortcodes.php             # Frontend shortcodes
├── assets/
│   └── css/
│       ├── settings.css               # Admin settings styles
│       └── frontend.css               # Frontend invoice styles
├── src/
│   ├── index.js                       # React component
│   └── index.scss                     # Component styles
├── build/                             # Compiled assets
├── composer.json                      # PHP dependencies
├── package.json                       # NPM dependencies
└── webpack.config.js                  # Build configuration

Key Classes

FastAPIClient (includes/Client/FastAPIClient.php)

Handles HTTP communication with Invoice Now backend:

  • get() - GET requests
  • post() - POST requests
  • put() - PUT requests
  • test_connection() - Test API connectivity

InvoiceService (includes/Services/InvoiceService.php)

Business logic for invoice operations:

  • create_invoice_from_order() - Create invoice from WooCommerce order
  • get_invoices() - Retrieve invoices
  • update_invoice_status() - Update invoice status

WooCommerceIntegration (includes/Integrations/WooCommerceIntegration.php)

Hooks into WooCommerce events:

  • on_order_created() - Handle new orders
  • on_order_status_changed() - Sync status changes
  • get_order_invoice() - Retrieve invoice for order

Settings (includes/Admin/Settings.php)

Manages plugin configuration:

  • get_settings() - Retrieve all settings
  • get_setting() - Get specific setting
  • is_enabled() - Check if feature is enabled

Data Flow

Order to Invoice Sync

WooCommerce Order Created
    ↓
WooCommerceIntegration::on_order_created()
    ↓
InvoiceService::create_invoice_from_order()
    ↓
FastAPIClient::create_invoice()
    ↓
Invoice Now API
    ↓
Invoice Created in Database
    ↓
Store Invoice ID in Order Meta
    ↓
Add Order Note

Status Sync

WooCommerce Order Status Changed
    ↓
WooCommerceIntegration::on_order_status_changed()
    ↓
Retrieve Stored Invoice ID
    ↓
InvoiceService::update_invoice_status()
    ↓
FastAPIClient::update_invoice()
    ↓
Invoice Now API
    ↓
Invoice Status Updated

Hooks & Filters

WordPress Hooks

The plugin registers several WordPress actions:

  • admin_init - Initialize admin functionality
  • admin_menu - Register admin pages
  • admin_enqueue_scripts - Load admin assets
  • wp_enqueue_scripts - Load frontend assets
  • woocommerce_order_status_changed - Listen for order status changes
  • woocommerce_checkout_order_created - Listen for new orders

Database Storage

Order Metadata

Invoice IDs are stored in WooCommerce order metadata:

// Get invoice ID for order
$invoice_id = get_post_meta( $order_id, '_invoicenow_invoice_id', true );

// Set invoice ID for order
update_post_meta( $order_id, '_invoicenow_invoice_id', $invoice_id );

Plugin Options

Settings are stored in WordPress options:

// Retrieve all settings
$settings = get_option( 'invoicenow_api_settings' );

// Individual setting
$api_url = $settings['api_url'];
$api_key = $settings['api_key'];
$tenant_id = $settings['tenant_id'];
$sync_enabled = $settings['enable_woocommerce_sync'];

Error Handling

The plugin includes comprehensive error handling:

  1. API Connection Errors - Logged and displayed in admin notices
  2. Missing Configuration - Settings validation on sync attempts
  3. Order/Customer Issues - Error logging with order references
  4. Permission Checks - WordPress nonce verification for manual actions

Security

  • API Key Protection - Stored securely in WordPress options
  • Nonce Verification - CSRF protection for admin actions
  • Permission Checks - Current user capability verification
  • Input Sanitization - All user inputs are sanitized
  • Output Escaping - All output is properly escaped
  • Bearer Token Auth - Secure API authentication

Development

Building Assets

# Install dependencies
npm install

# Start development with hot reload
npm start

# Build for production
npm run build

# Format code
npm run format

# Lint JavaScript
npm run lint:js

# Lint CSS
npm run lint:css

PHP Coding Standards

The plugin follows WordPress coding standards:

# Install PHP CodeSniffer
composer global require "squizlabs/php_codesniffer=*"

# Check code standards
phpcs includes/

Testing

Local development with wp-env:

# Start local WordPress environment
wp-env start

# Access WordPress
# URL: http://localhost:8888
# Admin: http://localhost:8888/wp-admin
# Username: admin
# Password: password

# Stop environment
wp-env stop

Troubleshooting

Connection Test Fails

  1. Verify API URL is correct (no trailing slash)
  2. Check API key is valid
  3. Ensure tenant ID matches your account
  4. Verify Invoice Now backend is running
  5. Check firewall/network connectivity

Invoices Not Creating

  1. Ensure WooCommerce Sync is enabled
  2. Check PHP error logs
  3. Verify API credentials are correct
  4. Ensure customer has valid email address
  5. Check order has items and amount

Shortcodes Not Working

  1. Verify plugin is activated
  2. Check frontend CSS is enqueued
  3. Ensure Invoice Now API is configured
  4. Verify invoice ID/order ID is correct
  5. Check user permissions (for private invoices)

API Integration Details

Endpoints Used

The plugin uses the following Invoice Now API endpoints:

  • GET /invoices - List invoices
  • GET /invoices/{id} - Get single invoice
  • POST /invoices - Create invoice
  • PUT /invoices/{id} - Update invoice
  • GET /customers - List customers
  • POST /customers - Create customer

Request Headers

All API requests include:

Authorization: Bearer {api_key}
Content-Type: application/json

Response Handling

Responses are JSON and automatically parsed. Errors return:

{
  "detail": "Error message describing what went wrong"
}

Compatibility

  • WordPress: 5.0+
  • WooCommerce: 3.0+
  • PHP: 7.4+
  • Browsers: All modern browsers

Support

For issues and questions:

  1. Check the troubleshooting section above
  2. Review plugin settings and configuration
  3. Check WordPress and PHP error logs
  4. Contact Invoice Now support with API details

Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

License

GNU General Public License v3.0 - See LICENSE file for details

Changelog

Version 0.1.0

Initial release with:

  • Admin settings page for API configuration
  • WooCommerce order to invoice synchronization
  • Manual invoice creation from orders
  • Frontend shortcodes for displaying invoices
  • API key management
  • Order status synchronization
  • Comprehensive error handling and logging