Jump to content

Client Area Home Page Panels by using $productGroupId


H1kari

Recommended Posts

Hello,
I wanna change ClientAreaHomePagePanels in custom hook by using $productGroupId.
For example, if our clients have 'ACTIVE' products with $productGroupId = '1',
 we show them homePagePanel number one. If our clients have 'ACTIVE' products 
with $productGroupId = '2', we show them homePagePanel number two. If our clients 
don't have 'ACTIVE' products, than show nothing.

My code, but something is wrong:
 

 <?php

use WHMCS\View\Menu\Item;
use WHMCS\Service\Service;

add_hook('ClientAreaHomepagePanels', 1, function (Item $homePagePanels)
{
    $service = Menu::context('service');
    $gid = $service->product->productGroupId;
    $activeorders = $client->orders->where('status','Active')->count();
    $client = Menu::context('client');
    $clientid = $client->id;

if ($client && $activeorders > 0) {

if ($gid == '1') {
        $gettingStartedMessage = <<<EOT
        <p>If you are new here and would like help getting started, here is some resources you might find helpf$
                <center>
                        <a href="url" class="btn btn-default btn-sm">Installation Guide</a>
                        <a href="url" class="btn btn-default btn-sm">Importing Your Data</a>
                        <a href="url" class="btn btn-default btn-sm">Licensing FAQ</a>
                </center>
        </p>
EOT;
}

if ($gid == '2') {
        $gettingStartedMessage = <<<EOT
        <p> If you are new here and would like help getting started, here is some resources you might find help$
                <center>
                        <a href="url" class="btn btn-default btn-sm">Installation Guide</a>
                        <a href="url" class="btn btn-default btn-sm">Importing Your Data</a>
                </center>
        </p>
EOT;
}

if ($gid == '3') {
        $gettingStartedMessage = <<<EOT
        <p> If you are new here and would like help getting started, here is some resources you might find help$
                <center>
                        <a href="url" class="btn btn-default btn-sm">Installation Guide</a>
                </center>
        </p>
EOT;
}


 $supportTeam = <<< EOT
        <center>
                <p>Need help? <a href="submitticket.php">Contact our support team</a></p>
        </center>
EOT;


    $homePagePanels->addChild('GettingStarted', array(
        'label' => 'Getting Started Guide',
        'icon' => 'fa-thumbs-up',
        'order' => 999,
        'extras' => array(
            'color' => 'orange'
        ),
        'bodyHtml' => $gettingStartedMessage,
        'footerHtml' => $supportTeam
    ));
}});

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