Installation Guidance

Step 1 — Upload Module Files

Extract the package and upload the limit_purchase folder to your WHMCS addons directory:

<whmcs_root>/
└── modules/
    └── addons/
        └── limit_purchase/
            ├── limit_purchase.php    ← Main module file
            └── hooks.php             ← Cart validation & trial enforcement hooks

Step 2 — Set File Permissions

Ensure your web server can read the module files. On Linux/cPanel servers:

chmod -R 755 /path/to/whmcs/modules/addons/limit_purchase/

Step 3 — Activate the Module

  1. Navigate to System SettingsAddon Modules in your WHMCS Admin Panel.
  2. Locate “Product Limiter” and click Activate.
  3. Click Configure and complete the following:
    • License Key: Enter the license key provided with your purchase.
    • Access Control: Select which administrator roles should have access to the module (e.g., Full Administrator).
  4. Click Save Changes.

Note: Two database tables (mod_limit_purchase and mod_limit_purchase_config) are automatically created upon activation.

Step 4 — Configure Product Limits

  1. Access the module from AddonsProduct Limiter in the top navigation.
  2. Use the “Create New Rule” form on the left sidebar:
    • Target Product: Select the product to limit (products are listed by group for easier identification).
    • Purchase Limit: Set the maximum number of times a single client can purchase this product.
    • Error Message: Customize the message shown to clients when they hit the limit. Use {PNAME} as a placeholder for the product name.
    • Active Rule: Toggle on to enforce the rule immediately.
  3. Click Save Rule. The rule will appear in the “Enforced Product Limits” table on the right.

Step 5 — Configure Trial Enforcement (Optional)

If you want to require clients to purchase a free/trial product before ordering a paid package:

  1. In the Global Configuration bar at the top of the module:
    • Enable “Require Trial First”
    • Enable “Auto-redirect to Trial” toggle if you want clients to be automatically redirected to the trial product.
    • Customize the Trial Requirement Dialog Box Message (e.g., “You must activate a free trial before purchasing a paid plan.”).
  2. Click Save Settings.

Important: Trial enforcement identifies trial products as any product with a paytype of free in WHMCS. Ensure at least one free product exists for this feature to work.

Step 6 — Verify Hook Registration

The module automatically registers two WHMCS hooks: - ShoppingCartValidateCheckout — Intercepts checkout to enforce product limits and trial requirements. - ProductDelete — Automatically removes limit rules when a product is deleted from WHMCS.

No manual hook registration is required. To verify, check UtilitiesLogsModule Log for any limit_purchase entries during a test checkout.

Esta resposta lhe foi útil? 0 Usuários acharam útil (0 Votos)