Jump to content

Hook for ClientAreaPage


dounisaur

Recommended Posts

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! 

Link to comment
Share on other sites

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

Link to comment
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