AffordableDomainsCanada Posted August 18, 2015 Share Posted August 18, 2015 I want to create a box here, with the following 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} 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted August 18, 2015 Share Posted August 18, 2015 so what you need is the HTML syntax? 0 Quote Link to comment Share on other sites More sharing options...
AffordableDomainsCanada Posted August 18, 2015 Author Share Posted August 18, 2015 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.. 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted August 18, 2015 Share Posted August 18, 2015 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? 0 Quote Link to comment Share on other sites More sharing options...
AffordableDomainsCanada Posted August 18, 2015 Author Share Posted August 18, 2015 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} 0 Quote Link to comment Share on other sites More sharing options...
AffordableDomainsCanada Posted August 18, 2015 Author Share Posted August 18, 2015 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? 0 Quote Link to comment Share on other sites More sharing options...
othellotech Posted August 18, 2015 Share Posted August 18, 2015 Yes, simply move the 'if' into the div 0 Quote Link to comment Share on other sites More sharing options...
AffordableDomainsCanada Posted August 19, 2015 Author Share Posted August 19, 2015 Yes, simply move the 'if' into the div That did NOT work! 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted August 20, 2015 Share Posted August 20, 2015 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. 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. 0 Quote Link to comment Share on other sites More sharing options...
AffordableDomainsCanada Posted August 20, 2015 Author Share Posted August 20, 2015 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! 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.