Jump to content
luigidefra

how require clients to accept policy?

Recommended Posts

If I understood correctly, you need two checkboxes. One for TOS and one for Privacy Policy. That's pretty common in EU. In Italy it is mandatory (I suppose you're italian). The thing is that WHMCS doesn't support multiple checkboxes but you can solve the problem with javascript. Edit the following files:

  • templates/{YOUR_TEMPLATE}/clientregister.tpl
  • templates/orderforms/{YOUR_CART}/checkout

Add two dummy checkboxes (for TOS & Privacy) and make them required. Let's call them A and B. Then hide the checkbox of WHMCS. Let's call it C. Lastly, create a javascript that:

  • Ticks C when A and C have been selected
  • Unticks C when the above condition is false

Share this post


Link to post
Share on other sites

You can also add an extra tickbox (or multiple even) by adding a hook for it.

What we use for this is the following and it should work all the way up to the latest version of WHMCS, and even in V8, but test carefully as always 🙂

(change readextrarequirements and extra_requirements to something more useful, espcially if you are using multiple different ones)

 

<?php
/**
 * Example hook to provide an additional agreement requirement in checkout.
 *
 * @copyright Copyright (c) WHMCS Limited 2018
 * @license https://www.whmcs.com/eula/ WHMCS Eula
 */

use App;

add_hook('ClientAreaFooterOutput', 1, function ($vars)
{
    if (!defined('CLIENTAREA')) {
        return false;
    }

    if ($vars['filename'] != 'cart') {
        return false;
    }

    $a = App::getFromRequest('a');
    if (!in_array($a, array('view', 'checkout'))) {
        return false;
    }

    $readextrarequirements = App::getFromRequest('extra_requirements');

    $output = '<div class="text-center">
        <label class="checkbox-inline">
            <input type="checkbox" name="extra_requirements" value="1"' . ($readextrarequirements ? ' checked':'') . ' />
            &nbsp;
            I have read, agree and can comply with any applicable specific requirements. If you can not, please contact us Before placing any order to discuss the options.
        </label>
    </div>
    <br />';

    return '<script>
    jQuery("#btnCompleteOrder").before("' . preg_replace( "/\r|\n/", "", str_replace('"', '\"', $output)) . '");
</script>';
});

add_hook('ShoppingCartValidateCheckout', 1, function ($vars) {

    $readextrarequirements = App::getFromRequest('extra_requirements');

    if (!$readextrarequirements) {
        return 'You must confirm you read and agree with the requirements';
    }
});

add_hook('AfterShoppingCartCheckout', 1, function ($vars) {

    $orderId = $vars['OrderID'];
    $readextrarequirements = App::getFromRequest('extra_requirements');

    if ($readextrarequirements) {
        // Run any additional code post checkout here
        // For example logging of the agreement, time, IP, etc...
    }
});

Share this post


Link to post
Share on other sites
4 minutes ago, Hein said:

You can also add an extra tickbox (or multiple even) by adding a hook for it.

for the record, the original source of that hook code...

Share this post


Link to post
Share on other sites

Thanks Brian ... I Truly didn't remember where we got it and always Want to give credit where it is due..:-)

Edited by Hein

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated