dounisaur Posted November 21, 2019 Share Posted November 21, 2019 Hi community, I am new to these forums and the world of WHMCS. I am getting my head around creating hooks and have used some code snippets from these forums which have worked great. I have my originals hook for displaying hosting packages under the hosting page, and now i am trying to display the SSL options under the SSL page i am using the following for the SSL & the hosting packaged but i am just changing the gid value (in . this case 3 = ssl packages) <?php use Illuminate\Database\Capsule\Manager as Capsule; function ssl_products_hook($vars) { $client = Menu::context('client'); $products = Capsule::table('tblproducts') ->join('tblpricing', 'tblproducts.id', '=', 'tblpricing.relid') ->select('tblproducts.*','tblpricing.*') ->where('tblpricing.type', 'product') ->where('tblproducts.hidden','0') ->where('tblproducts.gid','3') ->groupBy('tblproducts.order') ->get(); $encodedata = json_encode($products); $decodedata = json_decode($encodedata, true); return array("myproducts" => $decodedata); } add_hook("ClientAreaPage", 1, "ssl_products_hook"); ?> and on the template page i have the following snippet to display the content {foreach $myproducts as $myproduct} <div class="col-lg-4 col-md-4 col-sm-12 col-xs-12 wow zoomInLeft"> <div class="pricing-table"> <div class="pricing-header"> <p class="pricing-title">{$myproduct.name}</p> <p class="pricing-rate" style="font-size:30px;">${$myproduct.annually}</p> <p class="pricing-term">Yearly</p> <a href="{$WEB_ROOT}/cart.php?a=add&pid={$myproduct.relid}" class="btn btn-custom">BUY NOW</a> </div> <div class="pricing-list"> <ul> <li><i class="fas fa-fw fa-server"></i>{$myproduct.description}</li> <li><i class="fas fa-fw fa-signal"></i><span>Unlimited Bandwidth</span></li> <li><i class="fas fa-fw fa-database"></i><span>mySQL Database</span> </li> <li><i class="fas fa-fw fa-cog"></i><span>cPanel, PHP, FTP & Email</span></li> </ul> </div> </div> </div> {/foreach} The above code has been taken from a thread from this community and i have just changed the GID value. which i thought would work.. But what is happening is that, when i click on SSL from the navigtation, i get the SSL certificate packages, but when i click on the hosting from the navigation i get the SSL displaying, even though the nav buttons are calling different pages and are using different templates and .php pages. I am a little confused on why i cant seem to display the different packages for Hosting and SSL Any help would be great! 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 23, 2019 Share Posted November 23, 2019 On 21/11/2019 at 23:08, dounisaur said: I am getting my head around creating hooks and have used some code snippets from these forums which have worked great. one of the best ways to learn. On 21/11/2019 at 23:08, dounisaur said: i am using the following for the SSL & the hosting packaged but i am just changing the gid value (in . this case 3 = ssl packages) if you have two hooks exactly the same, with the exception of the GID value, did you remember to give them different array names ? On 21/11/2019 at 23:08, dounisaur said: The above code has been taken from a thread from this community and i have just changed the GID value. which i thought would work.. this looks like my old hook code... 🙂 On 21/11/2019 at 23:08, dounisaur said: But what is happening is that, when i click on SSL from the navigtation, i get the SSL certificate packages, but when i click on the hosting from the navigation i get the SSL displaying, even though the nav buttons are calling different pages and are using different templates and .php pages. I am a little confused on why i cant seem to display the different packages for Hosting and SSL my suspicion is that you have two hooks both returning a $myproducts array - a quick fix might be, in the SSL hook, to change... return array("myproducts" => $decodedata); to... return array("sslproducts" => $decodedata); and then update your SSL template code to use $sslproducts instead of $myproducts 0 Quote Link to comment Share on other sites More sharing options...
dounisaur Posted November 23, 2019 Author Share Posted November 23, 2019 Thanks Brian! that worked a treat! after looking are your explanation it makes perfect sense! Thanks also for the original hook, thats has saved me a lot of time! 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.