Jump to content

Display Credit Balance In Six Template


sentq

Recommended Posts

  • 3 months later...
18 hours ago, HOSKIA INDIA said:

its widget is showing on almost every pages on client area, example product page, domain page, support page  etc, i need to show only on client area (homepage) and billing-related page, how its possible

the problem with this thread is that there are multiple versions of the same hook posted within it!

if you go back to page 2, I showed how you can make the sidebar only appear of specific pages.

Link to comment
Share on other sites

  • 1 month later...
  • 4 months later...

@brian!

Greetings. Thank you for your helpful contribution yet again.

Could you assist me to understand how best to show the info in the client email template?  I would make the email template in client area and send it when I see overpayment.

For example; customer makes an overpayment by using 1) credit card and 2) bank transfer

So it would be pertinent to write and tell them (amazing how many people pay twice and don't realise!)

 

Dear [carelessclientfirstname]

You have paid us twice, although we could spend it in the pub, we thought we'd advise you that:

  • Invoice #{$invoice_num} which was for a total of {$invoice_total} now has a balance of {$invoice_balance}
  • You've paid a total of {$invoice_amount_paid}, and the most recent payment was {$invoice_last_payment_amount} on {$invoice_date_paid}

^^^^^ that's all good....

This part I need help with because I want to show a list of transactions / payments made, along with the payment gateway, the amount and date - essentially allows client to understand why this error occured and probably not do it again.... 

{foreach from=$invoices item=invoice}   <<<<<<<< not sure about that
{$invoice_pay_method_type}: {$invoice_payment_method} {$invoice_last_payment_amount} on {$invoice_date_paid}
{/foreach}

 

 

Link to comment
Share on other sites

HI @sol2010

11 hours ago, sol2010 said:

This part I need help with because I want to show a list of transactions / payments made, along with the payment gateway, the amount and date - essentially allows client to understand why this error procured and probably not do it again.... 

{foreach from=$invoices item=invoice}   <<<<<<<< not sure about that
{$invoice_pay_method_type}: {$invoice_payment_method} {$invoice_last_payment_amount} on {$invoice_date_paid}
{/foreach}

the problem you have here is that an invoice email only has limited information for the current invoice - so there would be no $invoices array for you to loop through.

for an invoice with multiple transactions, the email template should have access to the last transaction details, but that's not enough for your purpose as you want details of all transactions.

therefore, you're going to need an EmailPreSend hook to pull those transaction details from the tblaccounts table for the specific invoice - in an EPS hook, and for an invoice-type template, the relid value would equal the invoice ID value... and that is the value you would use to search for in the table... probably, it would be useful for the hook to only return the transactions array if it finds more than one occurrence in its database query.

so that hook should give you a transactions array, and then it's just a case of looping through the array in the template and outputting as you want to.

Edited by brian!
Link to comment
Share on other sites

12 hours ago, harry1 said:

you wouldn't really need to do that, there was a bug in the original hook with regards to the handling of currencies that was easily solved... he PM'd and it was fixed within minutes.... the next day, his post is finally out of moderation. 🙄

Link to comment
Share on other sites

  • 2 months later...
  • 3 months later...
7 hours ago, JesusSuarz said:

I have made several modifications to the original, implement a couple of conditions to improve it.

I have published it here in case you want to see it: https://foroshosting.com/t/hook-para-agregar-bloque-de-saldo-al-area-de-cliente-de-whmcs.148/

It is in Spanish, however they can translate it, or add translation functions. 🙂

while I encourage and appreciate people contributions, its shame to see someone taking out the original contributor name, that is something I never understand!

Link to comment
Share on other sites

20 hours ago, sentq said:

while I encourage and appreciate people contributions, its shame to see someone taking out the original contributor name, that is something I never understand!

Hello, I apologize for the misunderstanding, you're right, I don't know why I took it off.

I have modified the theme and the code to add the real credits. I am very grateful to you.

Link to comment
Share on other sites

  • 3 months later...
30 minutes ago, ocastaned said:

How can I make possible to show the  "Available Credit" text into Spanish language?

which version of the hook are you using? there is a Lang::trans version of it somewhere (not sure in this thread), where the users language is used for the output.

Link to comment
Share on other sites

23 hours ago, ocastaned said:

But I am pretty sure I installed it more than one year ago.

try the following - pretty sure i've posted it before, but can't find the thread or specific post )might even be in this thread lol)...

<?php

use WHMCS\View\Menu\Item as MenuItem;
use WHMCS\Database\Capsule;

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']!=='clientarea' || $clientid===0){
        return;
    }
    $primarySidebar->addChild('Client-Balance', array('label' => Lang::trans('availcreditbal'), 'uri' => '#', 'order' => '1', 'icon' => 'fa-money'));
    $balancePanel = $primarySidebar->getChild('Client-Balance')->moveToBack()->setOrder(0);
    $balancePanel->addChild('balance-amount', array('uri' => 'clientarea.php?action=addfunds','label' => '<h4 style="text-align:center;">'.formatcurrency($client->credit,$client->currencyId).'</h4>','order' => 1));
    $balancePanel->setFooterHtml('<a href="clientarea.php?action=addfunds" class="btn btn-success btn-sm btn-block"><i class="fa fa-plus"></i> '.Lang::trans('addfunds').'</a>');
});

1K3tww5.pnga7bEFKK.png

Link to comment
Share on other sites

6 hours ago, brian! said:

try the following - pretty sure i've posted it before, but can't find the thread or specific post )might even be in this thread lol)...


<?php

use WHMCS\View\Menu\Item as MenuItem;
use WHMCS\Database\Capsule;

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']!=='clientarea' || $clientid===0){
        return;
    }
    $primarySidebar->addChild('Client-Balance', array('label' => Lang::trans('availcreditbal'), 'uri' => '#', 'order' => '1', 'icon' => 'fa-money'));
    $balancePanel = $primarySidebar->getChild('Client-Balance')->moveToBack()->setOrder(0);
    $balancePanel->addChild('balance-amount', array('uri' => 'clientarea.php?action=addfunds','label' => '<h4 style="text-align:center;">'.formatcurrency($client->credit,$client->currencyId).'</h4>','order' => 1));
    $balancePanel->setFooterHtml('<a href="clientarea.php?action=addfunds" class="btn btn-success btn-sm btn-block"><i class="fa fa-plus"></i> '.Lang::trans('addfunds').'</a>');
});

1K3tww5.pnga7bEFKK.png

 

It worked amazing! Thank you so much 🙂

Link to comment
Share on other sites

  • 1 month later...
  • 1 year later...

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.

×
×
  • 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