diff --git a/whmcs-pricing-plugin/README.md b/whmcs-pricing-plugin/README.md new file mode 100644 index 0000000..09cb51b --- /dev/null +++ b/whmcs-pricing-plugin/README.md @@ -0,0 +1,160 @@ +# 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 + + € + 24.00 + per year + +``` + +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+ diff --git a/whmcs-pricing-plugin/includes/admin-settings.php b/whmcs-pricing-plugin/includes/admin-settings.php index 39390f5..65072f4 100644 --- a/whmcs-pricing-plugin/includes/admin-settings.php +++ b/whmcs-pricing-plugin/includes/admin-settings.php @@ -137,6 +137,46 @@ class WHMCS_Pricing_Admin { ) ); + add_settings_field( + 'decimal_separator', + __('Decimal Separator', 'whmcs-pricing'), + array($this, 'render_select_field'), + 'whmcs-pricing', + 'whmcs_pricing_display_section', + array( + 'name' => 'decimal_separator', + 'options' => array( + '.' => __('Period (.) - Example: 1,234.56', 'whmcs-pricing'), + ',' => __('Comma (,) - Example: 1.234,56', 'whmcs-pricing') + ), + 'description' => __('Choose the character to use as decimal separator', 'whmcs-pricing') + ) + ); + + add_settings_field( + 'hide_currency_symbol', + __('Hide Currency Symbol', 'whmcs-pricing'), + array($this, 'render_checkbox_field'), + 'whmcs-pricing', + 'whmcs_pricing_display_section', + array( + 'name' => 'hide_currency_symbol', + 'label' => __('Hide currency symbol/prefix from prices', 'whmcs-pricing') + ) + ); + + add_settings_field( + 'hide_billing_cycle', + __('Hide Billing Cycle', 'whmcs-pricing'), + array($this, 'render_checkbox_field'), + 'whmcs-pricing', + 'whmcs_pricing_display_section', + array( + 'name' => 'hide_billing_cycle', + 'label' => __('Hide billing cycle text (e.g., "per month") from prices', 'whmcs-pricing') + ) + ); + // Performance Settings Section add_settings_section( 'whmcs_pricing_performance_section', @@ -439,6 +479,28 @@ class WHMCS_Pricing_Admin { + + +
+ + 'SGD - Singapore Dollar (S$)', 'NZD' => 'NZD - New Zealand Dollar (NZ$)', 'MXN' => 'MXN - Mexican Peso (Mex$)', - 'ZAR' => 'ZAR - South African Rand (R)' + 'ZAR' => 'ZAR - South African Rand (R)', + 'ARS' => 'ARS - Argentine Peso ($)' ); ?>