Jump to content

How to display Available Credit in cart.php


Recommended Posts

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>'

);

}

 

}

);

Link to comment
Share on other sites

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. :idea:

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