Implement version 0.0.1 - Licensed Product type for WooCommerce

Add complete plugin infrastructure for selling software with license keys:

- New "Licensed Product" WooCommerce product type
- License key generation (XXXX-XXXX-XXXX-XXXX format) on order completion
- Domain-based license validation system
- REST API endpoints (validate, status, activate, deactivate)
- Customer My Account "Licenses" page
- Admin license management under WooCommerce > Licenses
- Checkout domain field for licensed products
- Custom database tables for licenses and product versions
- Twig template engine integration
- Full i18n support with German (de_CH) translation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-21 18:55:18 +01:00
parent 8a4802248c
commit 404083f023
22 changed files with 3746 additions and 0 deletions

121
README.md Normal file
View File

@@ -0,0 +1,121 @@
# WC Licensed Product
A WooCommerce plugin to sell software products using license keys with domain-based validation.
## Description
WC Licensed Product adds a new product type "Licensed Product" to WooCommerce, enabling you to sell software with automatically generated license keys. Licenses are bound to specific domains and can be validated through a REST API.
## Features
- **Licensed Product Type**: New WooCommerce product type for software sales
- **Automatic License Generation**: License keys generated on order completion
- **Domain Binding**: Licenses are bound to customer-specified domains
- **REST API**: Public endpoints for license validation and management
- **Customer Account**: Customers can view their licenses in My Account
- **Admin Management**: Full CRUD interface for license management
- **Version Binding**: Optional binding to major software versions
- **Expiration Support**: Set license validity periods or lifetime licenses
## Requirements
- WordPress 6.0 or higher
- WooCommerce 10.0 or higher
- PHP 8.3 or higher
## Installation
1. Upload the `wc-licensed-product` folder to `/wp-content/plugins/`
2. Activate the plugin through the 'Plugins' menu in WordPress
3. The plugin will create necessary database tables on activation
## Usage
### Creating a Licensed Product
1. Go to Products > Add New
2. Select "Licensed Product" from the product type dropdown
3. Configure the product price in the General tab
4. Set license options in the "License Settings" tab:
- **Max Activations**: Number of domains allowed per license
- **License Validity**: Days until expiration (empty = lifetime)
- **Bind to Major Version**: Lock license to current major version
- **Current Version**: Your software's current version
### Customer Checkout
When a customer purchases a licensed product, they must enter the domain where they will use the license during checkout.
### Viewing Licenses
- **Customers**: My Account > Licenses
- **Administrators**: WooCommerce > Licenses
## REST API
### Validate License
```http
POST /wp-json/wc-licensed-product/v1/validate
Content-Type: application/json
{
"license_key": "XXXX-XXXX-XXXX-XXXX",
"domain": "example.com"
}
```
### Check Status
```http
POST /wp-json/wc-licensed-product/v1/status
Content-Type: application/json
{
"license_key": "XXXX-XXXX-XXXX-XXXX"
}
```
### Activate License
```http
POST /wp-json/wc-licensed-product/v1/activate
Content-Type: application/json
{
"license_key": "XXXX-XXXX-XXXX-XXXX",
"domain": "newdomain.com"
}
```
### Deactivate License
```http
POST /wp-json/wc-licensed-product/v1/deactivate
Content-Type: application/json
{
"license_key": "XXXX-XXXX-XXXX-XXXX",
"domain": "example.com"
}
```
## License Statuses
- **Active**: License is valid and usable
- **Inactive**: License has been deactivated
- **Expired**: License validity period has ended
- **Revoked**: License has been manually revoked by admin
## Support
For issues and feature requests, please visit:
<https://src.bundespruefstelle.ch/magdev/wc-licensed-product/issues>
## Author
Marco Graetsch
## License
GPL-2.0-or-later