When running a web hosting business with WHMCS, managing multiple currencies can sometimes confuse guest users. In WHMCS, once a client registers an account, their currency is locked based on their initial setup or location, and they cannot change it later from their client area.

Therefore, it is crucial to remind guest users to choose their preferred currency before they proceed to checkout.

In this tutorial, we will show you how to display an important currency selection notice on the WHMCS Review & Checkout (cart.php?a=view) page exclusively for non-logged-in (guest) users.


By creating a custom template variable, we can seamlessly render a beautiful Bootstrap warning alert precisely where we want it.

Here is the step-by-step implementation.


Step 1: Create the WHMCS Action Hook

First, we need to create a hook file that checks if the user is a guest and then registers our custom notification template variable.

  1. Access your server via FTP or File Manager.

  2. Navigate to the /includes/hooks/ directory.

  3. Create a new file named cart_currency_notice.php.

  4. Paste the following PHP code into the file and save it:

<?php
/**
 * WHMCS Currency Selection Notice Hook for Guest Users
 * Display an explicit currency choose warning on the view cart page.
 */

if (!defined("WHMCS")) {
    die("This file cannot be accessed directly");
}

add_hook('ClientAreaPageCart', 1, function($vars) {
    // Check if the user is not logged in (Guest)
    if (!isset($_SESSION['uid'])) {
        
        // Define the custom alert HTML box
        $noticeHtml = '
        <div class="alert alert-warning" role="alert" style="margin-top: 10px; margin-bottom: 20px; border-left: 5px solid #f0ad4e; font-size: 13px; padding: 10px 15px;">
            <i class="fas fa-exclamation-triangle"></i> <strong>Important:</strong> Please choose your preferred currency now; it cannot be changed after registering your account.
        </div>';

        // Return the notice as a custom template variable
        return array(
            'custom_currency_notice' => $noticeHtml
        );
    }
});

Step 2: Update Your Order Form Template File

Now that our hook is passing the $custom_currency_notice variable to the cart page, we need to tell WHMCS where to display it. Since we only want this on the final cart review page, we will edit the viewcart.tpl file.

  1. Go to your active order form template directory. (In this example, we are using the default Standard Cart: /templates/orderforms/standard_cart/).

  2. Open the viewcart.tpl file for editing.

  3. Find the following standard heading line (Review & Checkout):

    <h1>{$LANG.cartreviewcheckout}</h1>
    
  4. Right underneath that heading line, insert our custom template variable tag:

    {$custom_currency_notice}
    
  5. Save the file.


Step 3: Clear WHMCS Template Cache

To see the changes immediately, clear your WHMCS template cache:

  • Log into your WHMCS Admin Area.

  • Navigate to WHMCS Admin Panel > Utilities > System > System Cleanup > Empty Template Cache : Go.

Conclusion

That’s it! Now, whenever a guest visitor navigates to shopping cart review page (cart.php?a=view), they will see a distinct, clean warning message prompting them to double-check their currency selector before finalizing registration. As soon as a client logs in, the notice dynamically disappears, ensuring a clutter-free user experience.

Found this tutorial helpful? Let us know in the comments below, or share your thoughts on optimizing the WHMCS checkout flow!

Leave A Comment