Jump to content

adding a menu box in the client area homepage


Recommended Posts

I was thinking of something like this.

 

http://docs.whmcs.com/Working_With_Client_Area_Home_Page_Panels#Add_a_promotional_offer_panel

 

I currently am using this to display promotions available, and its being displayed in the client area,

 

I have tried added a second hook php file, to use for the credits, but when I modify the second hook file for the credits, it modifys the promotions hook on the client page.

 

I just want a panel in the client area with the credit being displayed..

Link to comment
Share on other sites

is both hook files use the same name here:

$homePagePanels->addChild('thanks', array(....

 

you see this "thanks" work? it need to be unique every-time you need to add more panels, menu items, etc.

 

so possibly you did it right but the second hook file override the first hook file as they both share the same unique name, is this the case?

Link to comment
Share on other sites

Yes that was my problem!

 

Now this is what I have so far, but the {if statement is not showing properly.

 

 

<?php

use WHMCS\View\Menu\Item;

 

add_hook('ClientAreaHomepagePanels', 1, function (Item $homePagePanels)

{

$thankYouMessage = <<<EOT

 

 

{if $clientsstats.incredit == true}<div id='creditbalance'>There is currently a credit on your account in the amount of ${$clientsdetails.credit}. This will be applied to future invoices.</div>{/if}

 

 

EOT;

 

// Add a homepage panel with a link to a free month promo and mode it to the

// front of the panel list.

$homePagePanels->addChild('credits', array(

'label' => 'Credits',

'icon' => 'fa-bullhorn',

'order' => 200,

'extras' => array(

'color' => 'red',

'btn-link' => 'https://www.affordabledomains.ca/clientarea.php?action=addfunds',

'btn-text' => 'Add Funds',

'btn-icon' => 'fa-arrow-right',

),

'bodyHtml' => $thankYouMessage,

'footerHtml' => '',

));

});

 

but I am having some troubles with this being displayed properly.

 

{if $clientsstats.incredit == true}<div id='creditbalance'>There is currently a credit on your account in the amount of ${$clientsdetails.credit}. This will be applied to future invoices.</div>{/if}
Link to comment
Share on other sites

I have been playing around with this and still no luck. I also got thinking, right now that code;

 

{if $clientsstats.incredit == true}<div id='creditbalance'>There is currently a credit on your account in the amount of ${$clientsdetails.credit}. This will be applied to future invoices.</div>{/if}

 

is only displayed when the client has a credit, so the panel would be blank or should be blank when the client has NO credit.

 

I would like it so when the user has NO credit it says;

 

There is currently a credit on your account in the amount of $0.00.

 

and when the user has a credit;

 

There is currently a credit on your account in the amount of ${$clientsdetails.credit}.

 

I dont want it to be blank, can the hook be coded in a way that this code to call the credit?

Link to comment
Share on other sites

isn't the problem ultimately caused by you trying to use Smarty variables in the hook? :?:

 

I think you'll first need to assign their values to PHP variables and then you can use them in your conditions and output.

 

try the following hook...

 

<?php
use WHMCS\User\Client;
use WHMCS\View\Menu\Item;

add_hook('ClientAreaHomepagePanels', 1, function (Item $homePagePanels)
{
$currentUser = Client::find($_SESSION['uid']);
$clientID = $currentUser->id;
$clientInfo = Client::find($clientID);
$creditbalance = $clientInfo->credit;

if ($creditbalance>0)
{
   $creditMessage = <<<EOT
   <p>There is currently a credit on your account in the amount of $$creditbalance. This will be applied to future invoices.</p>
EOT;
}
else
{
   $creditMessage = <<<EOT
   <p>There is currently a credit on your account in the amount of $$creditbalance.</p>
EOT;
}    

// Add a credit balance panel.
$homePagePanels->addChild('credits', array(
'label' => 'Credits',
'icon' => 'fa-usd',
'order' => 200,
'extras' => array(
   'color' => 'red',
   'btn-link' => 'clientarea.php?action=addfunds',
   'btn-text' => 'Add Funds',
   'btn-icon' => 'fa-arrow-right',
),
'bodyHtml' => $creditMessage,
'footerHtml' => '',
));
});

tested on my v6 dev and it works for me - don't know if it's the 'correct' way to do it, but the v6 documentation is so shockingly poor and incomplete, that this was not easy to solve... I understand it now, and all the potential exciting things it can do - but we really shouldn't need to be making quantum leaps (and trial & error guesses) to figure something like this out. :mad:

 

anyway - if the user has a zero credit balance, it will say "There is currently a credit on your account in the amount of $x" (where x is the balance); if the user has a positive credit balance, then it also shows: "This will be applied to future invoices." - obviously you can change this text to suit your specific needs. :idea:

Link to comment
Share on other sites

I knew or had a feeling it was something with the code I was using. It was for a *.tpl file, not a php file..

 

I am not the best coder, I can play around with things and with help from awesome people like yourself, I can get stuff like this done.

 

This new v6 is troublesome, it is a lot harder to customize things, for the basic user like myself. I am starting to learn the whole hook feature and how it works, it is a good idea just hard to get used to.

 

Thank you everyone who helped, I greatly appreciate everyones help!

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