Nyan Posted November 10, 2016 Share Posted November 10, 2016 I set the following code in /includes/hooks/. I chanded code that display Available Credit in clientarea.php. But it is not displayed. Please teach me correct code. <?php /** * Display Client's Credit Balance in Client Area * @author WHMCMS * @link http://www.whmcms.com * @since WHMCS v6.0.0+ */ use WHMCS\View\Menu\Item as MenuItem; use Illuminate\Database\Capsule\Manager as Capsule; # Add Balance To Sidebar add_hook('ClientAreaPrimarySidebar', 1, function(MenuItem $primarySidebar){ $filename = basename($_SERVER['REQUEST_URI'], ".php"); $parseFile = explode('.', $filename); $client = Menu::context("client"); $clientid = intval($client->id); if ($parseFile['0']!=='cart' || $clientid===0){ return; } if ($client->credit > 0) { $primarySidebar->addChild('Client-Balance', array( 'label' => Lang::trans('availcreditbal'), //'uri' => '#', 'order' => '1', 'icon' => 'fa-money' )); //'label' => "Available Credit", # Get Currency $getCurrency = Capsule::table('tblcurrencies')->where('id', $client->currency)->get(); # Retrieve the panel we just created. $balancePanel = $primarySidebar->getChild('Client-Balance'); // Move the panel to the end of the sorting order so it's always displayed // as the last panel in the sidebar. $balancePanel->moveToBack(); $balancePanel->setOrder(0); # Add Balance. $balancePanel->addChild('balance-amount', array( //'uri' => 'clientarea.php?action=addfunds', 'label' => '<h4 style="text-align:center;">'.$getCurrency['0']->prefix.number_format($client->credit).' '. $getCurrency['0']->suffix.'</h4>', 'order' => 1 )); $balancePanel->setFooterHtml( '<a href="knowledgebase.php?action=displayarticle&id=1261" class="btn btn-success btn-sm btn-block"> <i class="fa fa-plus"></i> How to Apply Credit </a>' ); } } ); 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 10, 2016 Share Posted November 10, 2016 the cart doesn't use a Primary Sidebar, so you would have to change it to a Secondary Sidebar... <?php /** * Display Client's Credit Balance in Client Area * @author WHMCMS * @link www.whmcms.com * @since WHMCS v6.0.0+ */ use WHMCS\View\Menu\Item as MenuItem; use Illuminate\Database\Capsule\Manager as Capsule; # Add Balance To Sidebar add_hook('ClientAreaSecondarySidebar', 1, function(MenuItem $secondarySidebar){ $filename = basename($_SERVER['REQUEST_URI'], ".php"); $parseFile = explode('.', $filename); $client = Menu::context("client"); $clientid = intval($client->id); if ($parseFile['0']!=='cart' || $clientid===0){ return; } if ($client->credit > 0) { $secondarySidebar->addChild('Client-Balance', array( 'label' => Lang::trans('availcreditbal'), //'uri' => '#', 'order' => '1', 'icon' => 'fa-money' )); //'label' => "Available Credit", # Get Currency $getCurrency = Capsule::table('tblcurrencies')->where('id', $client->currency)->get(); # Retrieve the panel we just created. $balancePanel = $secondarySidebar->getChild('Client-Balance'); // Move the panel to the end of the sorting order so it's always displayed // as the last panel in the sidebar. $balancePanel->moveToBack(); $balancePanel->setOrder(0); # Add Balance. $balancePanel->addChild('balance-amount', array( //'uri' => 'clientarea.php?action=addfunds', 'label' => '<h4 style="text-align:center;">'.$getCurrency['0']->prefix.number_format($client->credit).' '. $getCurrency['0']->suffix.'</h4>', 'order' => 1 )); $balancePanel->setFooterHtml( '<a href="knowledgebase.php?action=displayarticle&id=1 261" class="btn btn-success btn-sm btn-block"> <i class="fa fa-plus"></i> How to Apply Credit </a>' ); } } ); also, remember that the client has to be logged in AND have a credit balance greater than 0 for the sidebar to appear. 0 Quote Link to comment Share on other sites More sharing options...
Nyan Posted November 11, 2016 Author Share Posted November 11, 2016 Thank you as always. I did it. 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.