suportgc Posted August 23, 2017 Share Posted August 23, 2017 Hello good morning, I'd like to know how to hide Pay button on invoice when due I need to create a hook for this and I have no programming knowledge. I would like to hide the button and if possible insert a message or a button to open called. Ex: Please contact financial support. Or a button (Contact financial sector) Can you help me ? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted August 23, 2017 Share Posted August 23, 2017 some screenshots might help us to determine which page you are talking about - and which template you are using! 0 Quote Link to comment Share on other sites More sharing options...
suportgc Posted August 23, 2017 Author Share Posted August 23, 2017 Hello, @brian! I really forgot to post this information. See below. Page site.com/viewinvoice.php I use the Six template I just duplicated the template and put the name gsw_novo 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted August 23, 2017 Share Posted August 23, 2017 if it were me, i'd be tempted to just edit the viewinvoice.tpl template and change... {if $status eq "Unpaid" || $status eq "Draft"} <div class="small-text"> {$LANG.invoicesdatedue}: {$datedue} </div> <div class="payment-btn-container" align="center"> {$paymentbutton} </div> {/if} to... {if $status eq "Unpaid" || $status eq "Draft"} <div class="small-text"> {$LANG.invoicesdatedue}: {$datedue} </div> {if {$date|date_format:"%d/%m/%y"} lt {$duedate|date_format:"%d/%m/%y"}} <div class="payment-btn-container" align="center"> {$paymentbutton} </div> {/if} {/if} that should hide the button... 0 Quote Link to comment Share on other sites More sharing options...
suportgc Posted August 23, 2017 Author Share Posted August 23, 2017 Got it. I am wanting to do as a hook, so I do not have problems with updates. Can you tell me how to do it? What about displaying the new message, how can I do it? I'm quite a layman in this part. 0 Quote Link to comment Share on other sites More sharing options...
suportgc Posted August 23, 2017 Author Share Posted August 23, 2017 Just to facilitate. The support team gave me the second message. If you were to go down the route of using an action hook, I imagine you might be best using the ClientAreaPageViewInvoice hook point. The paymentbutton variable may be an available variable in that hook point, in which case the value could potentially be modified to based upon the duedate value to display such a message in place of the payment button. But I do not know how to put this information together. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted August 24, 2017 Share Posted August 24, 2017 Got it.I am wanting to do as a hook, so I do not have problems with updates. but you've renamed the theme, so updates won't affect this code! and updates can affect any code, template or hook... hooks are never a 100% guarantee of preventing update issues. Can you tell me how to do it? I posted the Smarty code because it was shorter and quicker, but if you really want to do it as a hook - to remove the button on overdue invoices... <?php # Invoice Hide Pay Button Hook # Written by brian! function invoice_hide_button_hook($vars) { $today = strtotime($vars['date']); $duedate = strtotime($vars['duedate']); if($today > $duedate) { return array("paymentbutton" => ""); } } add_hook("ClientAreaPageViewInvoice", 1, "invoice_hide_button_hook"); What about displaying the new message, how can I do it? if you want to display a message (you might need to add css styling to this)... <?php # Invoice Hide Pay Button Hook # Written by brian! function invoice_hide_button_hook($vars) { $today = strtotime($vars['date']); $duedate = strtotime($vars['duedate']); if($today > $duedate) { return array("paymentbutton" => "This is a message..."); } } add_hook("ClientAreaPageViewInvoice", 1, "invoice_hide_button_hook"); if you want to use a link to the contact page as the output... <?php # Invoice Hide Pay Button Hook # Written by brian! function invoice_hide_button_hook($vars) { $today = strtotime($vars['date']); $duedate = strtotime($vars['duedate']); if($today > $duedate) { return array("paymentbutton" => '<a href="contact.php">Contact Us</a>'); } } add_hook("ClientAreaPageViewInvoice", 1, "invoice_hide_button_hook"); and if you want to use a button, then that's just some different HTML to replace the above href code - there are many ways to do that and i'm sure Googling will tell you more about the usable options, but one way would be to use Bootstrap... <?php # Invoice Hide Pay Button Hook # Written by brian! function invoice_hide_button_hook($vars) { $today = strtotime($vars['date']); $duedate = strtotime($vars['duedate']); if($today > $duedate) { return array("paymentbutton" => '<a href="contact.php" class="btn btn-default">Contact Us</a>'); } } add_hook("ClientAreaPageViewInvoice", 1, "invoice_hide_button_hook"); 0 Quote Link to comment Share on other sites More sharing options...
suportgc Posted August 24, 2017 Author Share Posted August 24, 2017 Amazing. Worked perfectly. Thanks a lot for the help. If it's not uncomfortable, could you tell me what I should study to learn these kinds of changes? Focusing on this part of hooks 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted August 24, 2017 Share Posted August 24, 2017 If it's not uncomfortable, could you tell me what I should study to learn these kinds of changes?Focusing on this part of hooks there's no quick way to learn.... you can take a look at https://developers.whmcs.com/hooks/ and that will walk you through the basics... ideally, you'll need some PHP knowledge, and would be helpful if you understood some SQL and how the database tables can be queried to get the information you want. the best thing to do is just play around with them - perhaps take some hooks posted here by myself or sentq, see what they do, figure out how they work and try to tweak them. though ideally don't do this on a live production site - as an incorrectly coded hook will blank out your client and/or admin areas! 0 Quote Link to comment Share on other sites More sharing options...
suportgc Posted August 24, 2017 Author Share Posted August 24, 2017 Many thanks, Brian. Have an excellent day. 0 Quote Link to comment Share on other sites More sharing options...
suportgc Posted August 25, 2017 Author Share Posted August 25, 2017 but you've renamed the theme, so updates won't affect this code! and updates can affect any code, template or hook... hooks are never a 100% guarantee of preventing update issues. I posted the Smarty code because it was shorter and quicker, but if you really want to do it as a hook - to remove the button on overdue invoices... <?php # Invoice Hide Pay Button Hook # Written by brian! function invoice_hide_button_hook($vars) { $today = strtotime($vars['date']); $duedate = strtotime($vars['duedate']); if($today > $duedate) { return array("paymentbutton" => ""); } } add_hook("ClientAreaPageViewInvoice", 1, "invoice_hide_button_hook"); if you want to display a message (you might need to add css styling to this)... <?php # Invoice Hide Pay Button Hook # Written by brian! function invoice_hide_button_hook($vars) { $today = strtotime($vars['date']); $duedate = strtotime($vars['duedate']); if($today > $duedate) { return array("paymentbutton" => "This is a message..."); } } add_hook("ClientAreaPageViewInvoice", 1, "invoice_hide_button_hook"); if you want to use a link to the contact page as the output... <?php # Invoice Hide Pay Button Hook # Written by brian! function invoice_hide_button_hook($vars) { $today = strtotime($vars['date']); $duedate = strtotime($vars['duedate']); if($today > $duedate) { return array("paymentbutton" => '<a href="contact.php">Contact Us</a>'); } } add_hook("ClientAreaPageViewInvoice", 1, "invoice_hide_button_hook"); and if you want to use a button, then that's just some different HTML to replace the above href code - there are many ways to do that and i'm sure Googling will tell you more about the usable options, but one way would be to use Bootstrap... <?php # Invoice Hide Pay Button Hook # Written by brian! function invoice_hide_button_hook($vars) { $today = strtotime($vars['date']); $duedate = strtotime($vars['duedate']); if($today > $duedate) { return array("paymentbutton" => '<a href="contact.php" class="btn btn-default">Contact Us</a>'); } } add_hook("ClientAreaPageViewInvoice", 1, "invoice_hide_button_hook"); Hey Brian, how's it going? Unfortunately the code is not working 100% Some invoices already expired, show the button to pay. Look what could it be ? <?php # Invoice Hide Pay Button Hook # Written by brian! function invoice_hide_button_hook($vars) { $today = strtotime($vars['date']); $duedate = strtotime($vars['duedate']); if($today > $duedate) { return array("paymentbutton" => '<a href="submitticket.php?step=2&deptid=2" class="btn btn-danger">Contate-nos</a>'); } } add_hook("ClientAreaPageViewInvoice", 1, "invoice_hide_button_hook"); 0 Quote Link to comment Share on other sites More sharing options...
edvancombr Posted August 25, 2017 Share Posted August 25, 2017 <?php function invoice_hide_button_hook($vars) { if (new DateTime() > DateTime::createFromFormat('d/m/Y', $vars['duedate'])) { return array("paymentbutton" => '<a href="submitticket.php?step=2&deptid=2" class="btn btn-danger">Contate-nos</a>'); } } add_hook("ClientAreaPageViewInvoice", 1, "invoice_hide_button_hook"); Screenshot https://prnt.sc/gcz5ux 0 Quote Link to comment Share on other sites More sharing options...
suportgc Posted August 25, 2017 Author Share Posted August 25, 2017 <?php function invoice_hide_button_hook($vars) { if (new DateTime() > DateTime::createFromFormat('d/m/Y', $vars['duedate'])) { return array("paymentbutton" => '<a href="submitticket.php?step=2&deptid=2" class="btn btn-danger">Contate-nos</a>'); } } add_hook("ClientAreaPageViewInvoice", 1, "invoice_hide_button_hook"); Screenshot https://prnt.sc/gcz5ux Perfect. Thank you Edvan. Problem solved. - - - Updated - - - Thank you for helping everyone. Brian, as Edvan checked, on my dashboard did not work, because my date version is d/m/Y. Brazilian pattern. Thank you all for the solution. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted August 25, 2017 Share Posted August 25, 2017 I was just about to post something similar to Edvan... I was originally testing on a v6 dev using d/m/y. 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.