A lightweight and extensible WordPress plugin designed to interact with the Dolibarr REST API. It provides an object-oriented interface to retrieve and manipulate Dolibarr entities such as proposals, invoices, products, and more.
- Connects to Dolibarr REST API using API key authentication
- Object-oriented PHP classes for main entities:
DolibarrProposalDolibarrInvoiceDolibarrProductDolibarrSupplierOrderDolibarrSupplierInvoiceDolibarrEvent
- Includes base class
DolibarrObjectfor shared behavior - Can be easily extended (e.g.,
OPCoachProposalinheritsDolibarrProposal)
- PHP 8.1 or higher
- WordPress 6.8.2 or higher
- A working Dolibarr instance (21.0 or higher) with REST API enabled
- Valid Dolibarr API key
- Clone this repository into your WordPress
wp-content/plugins/directory:
git clone https://github.com/yourusername/dolibarr-api.git wp-content/plugins/dolibarr-api-
Activate the plugin from the WordPress admin panel.
-
Define the required constants in your
wp-config.phpor a site-specific plugin:
define('DOLIBARR_API_KEY', 'your_api_key_here');
define('DOLIBARR_REST_URL', 'https://your.dolibarr.instance/api/index.php');
define('DOLIBARR_DOCUMENT_URL', 'https://your.dolibarr.instance/viewfile.php');Use the provided classes in your plugin or theme to access Dolibarr data. Example:
$proposal = DolibarrProposal::getProposal('PR12345');
if ($proposal) {
echo 'Client ID: ' . $proposal->getSocid();
}You can extend the base classes for customization. For example:
class MyProposal extends DolibarrProposal {
// Mus override this method to get MyProposal instances when calling ancestor methods.
protected static function getProposalClass(): string
{
return MyProposal::class;
}
public function getFinanceur(): ?string {
return $this->data->financeur ?? null;
}
}then call MyProposal::getProposal('XXXXX') to get instances of MyProposal.
Each base class can be extended to suit your needs. For instance, override getProposalClass() in your custom proposal class to return your subclass.
protected static function getProposalClass(): string {
return self::class;
}This project is licensed under the Eclipse Public License 2.0 (EPL-2.0).
See the LICENSE for details.