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
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.zipA 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
- Go to WordPress Admin → Plugins
- Find "Invoice Now WordPress Plugin"
- Click Activate
4. Configure API Settings
- Go to WooCommerce → Invoice Now Settings
- 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
- API URL: Your Invoice Now backend URL (e.g.,
- Click Test Connection to verify settings
- Save changes
Configuration
Getting Your API Credentials
- Log in to your Invoice Now dashboard
- Go to Settings → Developer → API Keys
- Create a new API key (or use existing)
- 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
- Go to WooCommerce → Invoice Now Settings
- Browse invoices and manage sync settings
- Manually create invoices for existing orders
Manual Invoice Creation
From the order edit page:
- Open any WooCommerce order
- Look for the Invoice Now section
- Click Create Invoice if no invoice exists
- 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 requestspost()- POST requestsput()- PUT requeststest_connection()- Test API connectivity
InvoiceService (includes/Services/InvoiceService.php)
Business logic for invoice operations:
create_invoice_from_order()- Create invoice from WooCommerce orderget_invoices()- Retrieve invoicesupdate_invoice_status()- Update invoice status
WooCommerceIntegration (includes/Integrations/WooCommerceIntegration.php)
Hooks into WooCommerce events:
on_order_created()- Handle new orderson_order_status_changed()- Sync status changesget_order_invoice()- Retrieve invoice for order
Settings (includes/Admin/Settings.php)
Manages plugin configuration:
get_settings()- Retrieve all settingsget_setting()- Get specific settingis_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 functionalityadmin_menu- Register admin pagesadmin_enqueue_scripts- Load admin assetswp_enqueue_scripts- Load frontend assetswoocommerce_order_status_changed- Listen for order status changeswoocommerce_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:
- API Connection Errors - Logged and displayed in admin notices
- Missing Configuration - Settings validation on sync attempts
- Order/Customer Issues - Error logging with order references
- 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
- Verify API URL is correct (no trailing slash)
- Check API key is valid
- Ensure tenant ID matches your account
- Verify Invoice Now backend is running
- Check firewall/network connectivity
Invoices Not Creating
- Ensure WooCommerce Sync is enabled
- Check PHP error logs
- Verify API credentials are correct
- Ensure customer has valid email address
- Check order has items and amount
Shortcodes Not Working
- Verify plugin is activated
- Check frontend CSS is enqueued
- Ensure Invoice Now API is configured
- Verify invoice ID/order ID is correct
- Check user permissions (for private invoices)
API Integration Details
Endpoints Used
The plugin uses the following Invoice Now API endpoints:
GET /invoices- List invoicesGET /invoices/{id}- Get single invoicePOST /invoices- Create invoicePUT /invoices/{id}- Update invoiceGET /customers- List customersPOST /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:
- Check the troubleshooting section above
- Review plugin settings and configuration
- Check WordPress and PHP error logs
- Contact Invoice Now support with API details
Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- 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