Files
WP-WHMCS-Pricing/README.md
T
2025-11-16 21:47:01 +01:00

161 lines
4.2 KiB
Markdown

# WHMCS Pricing
Display WHMCS product prices on WordPress using shortcodes. Lightweight, cached, works with Elementor.
## Installation
1. Upload ZIP via `Plugins > Add New > Upload Plugin`
2. Activate
3. Go to `Settings > WHMCS Pricing`
4. Enter your WHMCS credentials
## WHMCS Setup
**Step 1: Allow API Access by IP**
1. Go to `General Settings > Security` tab in WHMCS
2. Find **API IP Access Restriction**
3. Add your WordPress server IP address
4. Save changes
**Step 2: Generate API Credentials**
1. Go to `System Settings > API Credentials`
2. Click `Generate New API Credential`
3. Set Access Type to `Allowed`
4. Copy Identifier and Secret
Enter these in WordPress plugin settings along with your WHMCS URL.
**Security Note:** Without adding your WordPress server IP to API IP Access Restriction, the API calls will be blocked by WHMCS.
## Usage
Basic shortcode:
```
[whmcs_price product_id="123" billing_cycle="annually"]
```
### Parameters
- `product_id` - WHMCS product ID (required)
- `billing_cycle` - monthly, quarterly, semiannually, annually, biennially, triennially (default: monthly)
- `currency` - EUR, USD, GBP, etc. (uses plugin default if not specified)
- `format` - `default` or `no_decimals`
- `show_cycle` - `true` or `false` (default: true)
- `lang` - Language: `english`, `spanish`, `portuguese-pt`, `dutch`, `french`, `german`, `russian` (default: english)
- `class` - Custom CSS class
### Examples
```
[whmcs_price product_id="5" billing_cycle="annually"]
Output: €24.00 per year
[whmcs_price product_id="5" billing_cycle="monthly" format="no_decimals"]
Output: €3 per month
[whmcs_price product_id="5" currency="USD" show_cycle="false"]
Output: $3.50
[whmcs_price product_id="5" billing_cycle="annually" lang="spanish"]
Output: €24.00 por año
[whmcs_price product_id="5" billing_cycle="monthly" lang="dutch"]
Output: €3.00 per maand
```
### Translations
Billing cycle text is translated via `languages.json`. Supported languages:
- `english`
- `spanish`
- `portuguese-pt`
- `dutch`
- `french`
- `german`
- `russian`
Add more languages by editing `languages.json` in the plugin folder (uses WHMCS language naming).
```json
{
"italian": {
"monthly": "al mese",
"annually": "all'anno"
}
}
```
### Find Product IDs
In WHMCS admin:
1. `System Settings > Products/Services`
2. Click a product
3. ID is in URL: `?id=123`
## HTML Output
```html
<span class="whmcs-price" data-product-id="123" data-cycle="annually">
<span class="currency-symbol"></span>
<span class="price-amount">24.00</span>
<span class="billing-cycle">per year</span>
</span>
```
Style it with CSS:
```css
.whmcs-price { font-weight: bold; }
.price-amount { font-size: 24px; }
```
## Important Notes
**WHMCS uses `-1.00` for unavailable billing cycles.** If a product doesn't have monthly pricing in WHMCS, don't use `billing_cycle="monthly"` in the shortcode. Check your WHMCS product configuration first.
**Caching:** Prices are cached for 1 hour by default. Change this in plugin settings. Click "Clear All Cache" after updating prices in WHMCS.
**Errors:** Only administrators see error messages. Regular visitors see nothing if a price can't be loaded.
## Settings
- **WHMCS URL** - Your WHMCS installation URL (https://billing.yourdomain.com)
- **API Identifier** - From WHMCS API credentials
- **API Secret** - From WHMCS API credentials
- **Default Currency** - Fallback currency (EUR, USD, etc.)
- **Show Decimals** - Toggle decimal places globally
- **Cache Duration** - How long to cache API responses (seconds)
- **Debug Mode** - Enable logging, disable cache
## Troubleshooting
**Price shows as -1.00:**
- That billing cycle isn't available for this product in WHMCS
- Use a different `billing_cycle` parameter
**No price displays:**
- Check product ID exists in WHMCS
- Verify API credentials are correct
- Enable Debug Mode and check `/wp-content/debug.log`
- Clear plugin cache
**Wrong price:**
- Clear cache (prices are cached)
- Check currency matches WHMCS configuration
- Verify billing cycle is available
## Requirements
- WordPress 5.0+
- PHP 7.4+
- WHMCS 8.x with API access
- SSL recommended
## Support
**By:** ArkHost
**Sponsored by:** Duplika.com
**License:** GPL v2+