Jump to content

The display of Amount to Add and Apply Credit


Recommended Posts

you could do it in the template by just changing...

 

clientareaaddfunds.tpl

 

<input type="text" name="amount" id="amount" value="{$amount}" class="form-control" required />

to...

<input type="text" name="amount" id="amount" value="{$amount|floor}" class="form-control" required />

 

viewinvoice.tpl

<input type="text" name="creditamount" value="{$creditamount}" class="form-control" />

to...

<input type="text" name="creditamount" value="{$creditamount|floor}" class="form-control" />

that should effectively round down the number. :idea:

 

if you wanted to use hooks, then you'd get these variables from the template, perform your calculation on them (e.g floor, round, string/number format etc) and then send the result back to the template - you'd probably use the ClientAreaPageAddFunds and ClientAreaPageViewInvoice action hooks.

Link to comment
Share on other sites

Thank you brian!

I want to use hooks.

Based on your advice, I set the following code in /includes/hooks/.

I am not confident, because I am a beginner.

Is this a problem?

Please tell me correct method.

 

<?php

 

use WHMCS\View\Menu\Item as MenuItem;

 

add_hook('ClientAreaPageAddFunds', 1,

function($vars)

{

$amount = $vars['amount'];

return array(

"amount" => floor($amount)

);

}

);

 

add_hook('ClientAreaPageViewInvoice', 1,

function($vars)

{

$creditamount = $vars['creditamount'];

return array(

"creditamount" => floor($creditamount)

);

}

);

Link to comment
Share on other sites

it should work - personally, i'd have shortened it as below, but either should be ok...

 

<?php

use WHMCS\View\Menu\Item as MenuItem;

add_hook('ClientAreaPageAddFunds', 1, function($vars) {

   $amount = floor($vars['amount']);
   return array("amount" => $amount);
}
);

add_hook('ClientAreaPageViewInvoice', 1, function($vars) {

   $creditamount = floor($vars['creditamount']);
   return array("creditamount" => $creditamount);
}
); 

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