Jump to content

Recommended Posts

Posted (edited)

Following a question from @Mauwiks...

Quote

how do we link an available add-on product to any of our customers?

natively in WHMCS, there is no way to do this - but with the help of the attached hook, it is possible - just upload the hook to /includes/hooks

the hook currently includes EIGHT different parameter options - I can think of at least 4 more options that I could add, and may do so at a later date, but I think 8 is plenty to be going on with. 🙂

FfoZawQ.png

note: the addon's ID value can be found when in the URL when you edit that product addon in the admin area - configaddons.php?action=manage&id=1

  • Linking to one specific product addon
cart.php?gid=addons&id=1

TV1yV5v.png

  • Linking to Market Connect product addons by brand
cart.php?gid=addons&id=codeguard
cart.php?gid=addons&id=sitelock
cart.php?gid=addons&id=spamexperts
cart.php?gid=addons&id=ssl
cart.php?gid=addons&id=weebly

yQXCVRH.png

these addons are found by the hook searching whether specific terms are found at the START of the product addon descriptions, e.g Codeguard etc

  • Linking to multiple product addons
cart.php?gid=addons&multi[]=1&multi[]=32&multi[]=54

fzdv1Aa.png

  • Linking to a predefined group of product addons
cart.php?gid=addons&id=group1

$group1 is a predefined array of product addon IDs that you can edit in the hook..

$group1 = array(12,28,20);

sHKBWbC.png

you could, in theory, have multiple groups (arrays of addon IDs) predefined in the hook, but it's currently only coded for 1 group - but it would be simple enough to change.

  • if you pass a numeric addon ID value that doesn't exist for the particular client, then you'll get the no addons available error message...

KaEc7JW.png

... I did toy with the idea of showing all addons under those circumstances, but I decided against it for now - not least because it keeps the coding simplified! 😉

  • if you pass an undefined non-numeric id, e.g cart.php?gid=addons&id=brian, then there is nothing for the hook to remove and it will show all addons as per normal.
  • you can only use one parameter option in a URL - e.g., you can't use cart.php?gid=addons&id=43&multi[]=32

addons_mauwiks.php

Edited by brian!

Share this post


Link to post
Share on other sites

This is very much awesome @brian!

And I can't thank you enough for the effort of doing this. Thank you, thank you and more thanks. More power and everthing else. You're the best. I hope I can offer something as a token of appreciation. I will take note of this at the time being and will surely give back one day

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • By Remitur
      Starting from the code provided by @brian! in this post: 
      I realized a pop-up system which shows every time user log-in, but once a day (that's to say: if the user login 5 or more times in a day, the pop-up shows just one time, in order not to annoy him)
      The pop-up shows to the user his previous log-in time, and one "trick of the day" (randomly chosen one) 
       
      (IMHO, "trick of the day" is a great way to spread knowledge and marketing news without annoying the user)
      The code, in form of a hook (note: line #35 is for testing purposes only: remove or comment it):
      <?php //Show modal popup to clients, with a welcome message and a random trick of the day //original code by brian! , modified by Remitur function client_custom_headoutput_hook($vars) { $head_return = ''; $head_return = '<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js"></script> <script> $(document).ready(function() { $(\'#myModal\').appendTo("body"); function show_modal(){ $(\'#myModal\').modal(); } window.setTimeout(show_modal, 100); $(".dismiss").click(function() {}); }); </script>'; return $head_return; } add_hook("ClientAreaHeadOutput",1,"client_custom_headoutput_hook"); use Carbon\Carbon; function client_custom_headeroutput_hook($vars) { $client = Menu::context('client'); $lastlogin = Carbon::parse($client->lastLoginDate); $enddate = Carbon::parse($client->lastLoginDate)->addDays(1); // next line is just for testing purposes: remove it! $enddate = Carbon::today(); $today = Carbon::today(); $templatefile = $vars['templatefile']; if (empty($client->id)) { return; } if ($today >= $enddate and $templatefile == "clientareahome") { $header_return = ''; $header_return = '<div class="container"> <div class="modal fade" id="myModal" role="dialog"> <div class="modal-dialog modal-md"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">×</button> <h4 class="modal-title"><i class="fa fa-thumbs-up fa-lg"></i> '.Lang::trans('hello').', '.$client->firstname.'</h4> <p>Your last login has been '.$lastlogin.'</p> </div> <div class="modal-body"> <p>Trick of the day:</p> <p>'.Lang::trans ('tricks.'.rand(1,13)).'</p> </div> <div class="modal-footer"> <button type="button" class="btn btn-primary dismiss" data-dismiss="modal">'.Lang::trans('orderForm.close').'</button> </div> </div> </div> </div> </div>'; return $header_return; } } add_hook("ClientAreaHeaderOutput",1,"client_custom_headeroutput_hook"); The tricks are provided as an array of language variables; here there're 13, I guess that 30 is the minimum reasonable number; more is better.
      In the tricks you can provide also  internal and external links (just one here for example):
      #====================== tricks for popup ============================================ $_LANG['tricks']['1'] = "On DomainRegister you can register your own .com.br domain even if you have not a headquarter in Brazil"; $_LANG['tricks']['2'] = "Interface on DomainRegister is available in three different languages (English, Italian and Slovenian): select your preferred one using the flags in the upper right corner "; $_LANG['tricks']['3'] = "On DomainRegister you can renew any domain up to 10 years in advance (even those for which a multi-year renewal is not envisaged)"; $_LANG['tricks']['4'] = "If you manage a large number of domains, on DomainRegister you can create one or more DNS templates, to quickly implement complex DNS configurations for each single domain "; $_LANG['tricks']['5'] = "Using wildcard SSL certificates, with a single SSL certificate you can secure both your main domain and an unlimited number of subdomains on any number of different servers"; $_LANG['tricks']['6'] = "<a href=\"https://domainregister.international/dns-service.php\" target=\"_blank\">DomainRegister's DNS service</a> (which is free for any domain registered through us) got 100% uptime... since 2011!"; $_LANG['tricks']['7'] = "If you change the data of the registrant of a .com domain, you cannot transfer the domain for 60 days (sixty days lock)"; $_LANG['tricks']['8'] = "With DomainRegister's Linux Pro hosting plan, you get your own, dedicate european IP for your site"; $_LANG['tricks']['9'] = "DomainRegister's StarterMail starts with 5 email addresses and 5 GB archive space, and may be expanded up to 25 email addresses and 25 GB archive space; larger solutions are available upon request"; $_LANG['tricks']['10'] = "Keep your domains and services safe by protecting them with 2FA authentication: on DomainRegister it's free!"; $_LANG['tricks']['11'] = "trick 11"; $_LANG['tricks']['12'] = "trick 12"; $_LANG['tricks']['13'] = "trick 13";  
      Any idea to improve this hook is welcome!
       
       

    • By MaikelVE
      Hi!
      Does anybody know how I can change this: 
      To this:
      Either via a hook or in what template do I need to look for this? (I'm also using the Lagom theme)
    • By mfoland
      So I'm working with the licensing addon, and attempting to figure out the hook part..
       
      add_hook('LicensingAddonVerify', 1, function($vars) { return [ 'Hash' => 'Hash Here', ]; } ); The hash actually shows in the license how it should, but I'm trying to do it since I make several softwares, and not only one, so what I'm trying to do is something like
      if ($productid == "prodID number") { add_hook('LicensingAddonVerify', 1, function($vars) { return [ 'Hash' => 'Hash Here', ]; } ); } else -- run get different product It doesn't retrieve the product id at all.. What am I missing here? The hash is basically there to tell the system if a new version has been released. 
       
      Thanks
    • By WHMCS Josh
      In the latest release, you may have noticed that the Request Cancellation link in the left sidebar has been removed for free and one time products and services.
      This change was made in response to a bug report relating to one time products not being automatically cancelled. There was some concern that allowing cancellation requests for free and one time items, which have no next due date, and therefore terminate immediately on the following cron run could lead to irrevocable data loss.
      It is important to note that this is only a visual change that removes the link to submit a cancellation request. Submitting a cancellation request for a free service is still possible. If you wish to restore the option to cancel free products, you can do so using a hook.
      I've prepared some sample code that uses the ClientAreaPrimarySidebar hook point to achieve this.
      Here is the code below:
      <?php /** * This hook restores the Request Cancellation sidebar option on free services * * @author WHMCS Josh * @see https://developers.whmcs.com/hooks-reference/client-area-interface/#clientareaprimarysidebar * @see https://developers.whmcs.com/advanced/db-interaction/ */ use WHMCS\Database\Capsule; use WHMCS\View\Menu\Item; add_hook('ClientAreaPrimarySidebar', 1, function($primarySidebar) { // Get the handle for the Service Details Overview sidebar $serviceDetailsOverview = $primarySidebar->getChild('Service Details Overview'); // Make sure the handle is not null if (!is_null($serviceDetailsOverview)) { // Make sure the ID is available if (!empty($_REQUEST['id'])) { $serviceId = (int) $_REQUEST['id']; // Check if this is a free service $billingCycle = Capsule::table('tblhosting') ->where('id', $serviceId) ->value('billingcycle'); if ($billingCycle === 'Free Account') { // Add the cancellation request menu item for the service to the sidebar $serviceDetailsOverview->addChild( 'freeServiceCancellationRequest', [ 'name' => 'CancellationRequest', 'label' => 'Request Cancellation', 'uri' => '/clientarea.php?action=cancel&id=' . $serviceId, 'order' => 90, ] ); } } } }); To install this, you can simply add the code to a file in your /includes/hooks directory such as /includes/hooks/free_product_cancellation_request.php.
      For convenience, I've attached the completed hook file to this post here: free_product_cancellation_requests.php
      Below is also a screenshot of how this looked on my test installation of WHMCS 7.7.0.

      Please note that this is being provided only as an example and is not guaranteed to work with future versions of WHMCS.
      Feel free to modify it to suit your needs and I hope it helps!
    • By Cubeboy
      I need to get rid of the date when I add files on the admin side.
       
      when I upload a file the a clients account in the admin section, it displays in the client area and it time stamps it. how can I remove the time stamp? OR remove the whole hook and add it back with my own var?
       
       
      <?php
      use WHMCS\View\Menu\Item;
      add_hook('ClientAreaHomepagePanels', 1, function (Item $homePagePanels)
      {
      $homePagePanels->removeChild('your files:dateadded');
      });
  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

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