Integration Options
| Method | Best For | Difficulty |
|---|---|---|
| WordPress Plugin | WordPress sites | Easy (5 min) |
| HTML Embed | Any website | Easy (10 min) |
| REST API (Direct) | Custom apps, backend systems | Medium |
| Bootstrap Widget | Bootstrap sites | Easy (10 min) |
WordPress Plugin
Our WordPress plugin adds the CBM calculator to any page or post using a shortcode. Requires an active API subscription.
Installation
- Download the plugin from your account dashboard after subscribing
- In WordPress admin: Plugins → Add New → Upload Plugin
- Upload the
calculatecbm-plugin.zipfile - Activate the plugin
- Go to Settings → CBM Calculator → enter your API key
Usage
// Basic calculator:
[calculatecbm]
// With options:
[calculatecbm units="cm" show_weight="true" show_container="true" theme="light"]
// Minimal mode (single item):
[calculatecbm mode="basic"] Shortcode Parameters
| Parameter | Values | Default |
|---|---|---|
| units | cm, mm, m, in, ft | cm |
| show_weight | true, false | true |
| show_container | true, false | true |
| theme | dark, light, auto | dark |
| mode | basic, advanced | advanced |
| language | en, zh, hi, es, ar | en |
HTML Embed
Add the CBM calculator to any website with a single script tag. Works on any HTML page — no WordPress required.
<!-- Place this div where you want the calculator -->
<div id="cbm-calculator"></div>
<!-- Add before </body> -->
<script>
window.CBMConfig = {
apiKey: 'YOUR_API_KEY',
units: 'cm',
showContainerFit: true,
theme: 'dark'
};
</script>
<script src="https://api.calculatecbm.com/embed/v1/widget.js"></script> Bootstrap Integration
For Bootstrap-based sites, use our pre-styled Bootstrap-compatible widget:
<!-- Requires Bootstrap 5 -->
<div class="container">
<div id="cbm-bootstrap-widget"></div>
</div>
<script>
window.CBMConfig = { apiKey: 'YOUR_API_KEY', framework: 'bootstrap5' };
</script>
<script src="https://api.calculatecbm.com/embed/v1/widget-bootstrap.js"></script> Direct API Integration
For full control, call the API directly from your backend. See the API Documentation for all endpoints and parameters.
Frontend JavaScript Integration
// Important: Never expose your API key in frontend code.
// Proxy through your own backend instead:
// Your backend endpoint (PHP/Node/Python/etc.):
// POST /api/cbm-proxy
// → Calls api.calculatecbm.com/v1/calculate with your API key
// → Returns result to frontend
async function calculateCBM(items) {
const res = await fetch('/api/cbm-proxy', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ items })
});
return res.json();
} PHP Proxy Example
<?php
// /api/cbm-proxy.php
header('Content-Type: application/json');
$input = json_decode(file_get_contents('php://input'), true);
if(!isset($input['items'])) { http_response_code(400); echo json_encode(['error'=>'Missing items']); exit; }
$ch = curl_init('https://api.calculatecbm.com/v1/calculate');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode(['items' => $input['items']]),
CURLOPT_HTTPHEADER => ['Authorization: Bearer '.getenv('CBM_API_KEY'), 'Content-Type: application/json']
]);
echo curl_exec($ch);
curl_close($ch); Webhook Configuration (Enterprise)
Enterprise subscribers can configure webhooks to receive notifications:
POST https://api.calculatecbm.com/v1/webhooks
Authorization: Bearer YOUR_ENTERPRISE_API_KEY
{
"url": "https://yoursite.com/webhook/cbm",
"events": ["quota.warning", "quota.exceeded"],
"secret": "your_webhook_secret"
} 💡 Need help with integration? Email api@calculatecbm.com with your use case and we'll provide a custom integration guide.