John Kennedy Posted November 27, 2017 Share Posted November 27, 2017 I want to customise the way the Direct Debit option works. We have a 3rd party DD platform (gocardless) that interacts with Xero to process payments. GoCardless provides a unique link for each customer to set up their DD, so I have that link as a custom field in WHMCS. I want for WHMCS to open that custom field link when the "Pay Now" button is clicked with DD selected as payment method. Does anyone know how to achieve that? Link to comment Share on other sites More sharing options...
Solution brian! Posted November 27, 2017 Solution Share Posted November 27, 2017 10 hours ago, John Kennedy said: Does anyone know how to achieve that? with a hook or template tweak... in the above example, i'm just swapping the images used... but the principle would work with changing other aspects, or defining it to equal your custom field URL... though it's difficult to advise when I don't know what the default value of that button is, or the URL you want to use... but the template will have access to the client custom field, so it will be possible.... as a blind guess, it should be something along these lines of changing {$paymentbutton} to ... {if $paymentmethod == "PayPal"}<a href="{$clientsdetails.customfields2}" class="btn btn-default" role="button">Pay Now</a>{else}{$paymentbutton}{/if} obviously, it won't be PayPal, so you'll have to get the value of $paymentmethod... and it's unlikely to be customfields2, so you'll also have to find the correct client custom field... so adding a {debug} to the end of the code in viewinvoice.tpl will give you a popup window of variables and arrays... that will give you the two values you need to insert into the above code and then it's just a case of testing and tweaking the button design. Link to comment Share on other sites More sharing options...
John Kennedy Posted November 28, 2017 Author Share Posted November 28, 2017 Thanks! This should get me going in the right direction, for now at least. Link to comment Share on other sites More sharing options...
John Kennedy Posted November 28, 2017 Author Share Posted November 28, 2017 OK so there are 2 viewinvoice.tpl files: ./templates/five/viewinvoice.tpl ./templates/six/viewinvoice.tpl None of the changes I make in either of the files show up when I go to view an invoice as client. No debug popup either. Am I missing something here? Link to comment Share on other sites More sharing options...
John Kennedy Posted November 28, 2017 Author Share Posted November 28, 2017 Thanks brian! Worked like a charm after bit of tinkering. {if $paymentmethod == "Direct Debit"}<a href="{$clientsdetails.customfields3}" class="btn btn-default" role="button">Set Up DD</a>{else}{$paymentbutton}{/if} One thing of note however, for anyone looking to set up similar: do not set the custom field with the link as "URL/Link" leave it as "Text Box" or you'll be generating the following: <a href="<a href="{your.custom.link}" target="_blank">{your.custom.link}</a>" target="_blank"><a href="{your.custom.link}" target="_blank">{your.custom.link}</a></a> But that's if you want to have a button instead of a direct link. Link to comment Share on other sites More sharing options...
John Kennedy Posted November 29, 2017 Author Share Posted November 29, 2017 One more question. When clicking Pay All while in client panel the Direct Debit option still gives the default template. I'm guessing I need to modify a different template to update that to behave the same way as on individual invoices? Link to comment Share on other sites More sharing options...
brian! Posted November 29, 2017 Share Posted November 29, 2017 Hi John, 22 hours ago, John Kennedy said: Thanks brian! Worked like a charm after bit of tinkering. i'm glad my educated guess set you on the right track! 22 hours ago, John Kennedy said: One thing of note however, for anyone looking to set up similar: do not set the custom field with the link as "URL/Link" leave it as "Text Box" or you'll be generating the following: <a href="<a href="{your.custom.link}" target="_blank">{your.custom.link}</a>" target="_blank"><a href="{your.custom.link}" target="_blank">{your.custom.link}</a></a> But that's if you want to have a button instead of a direct link. technically, you could leave it using a URL/Link option (e.g if you need to use the customfield elsewhere as a pure link) and just adjust the Smarty code in viewinvoice.tpl... {if $paymentmethod == "Direct Debit"}{$clientsdetails.customfields3|replace:'target="_blank">':'class="btn btn-default" role="button">Set Up DD</a>'|replace:"`$clientsdetails.customfields3|strip_tags:false`":''}{else}{$paymentbutton}{/if} however, if the invoice page is the only place you're going to use this customfield, then choosing the text box option would be the simpler solution. Link to comment Share on other sites More sharing options...
brian! Posted November 29, 2017 Share Posted November 29, 2017 10 hours ago, John Kennedy said: I'm guessing I need to modify a different template to update that to behave the same way as on individual invoices? masspay.tpl ? personally, i've always disabled Mass Pay as an option as i've never trusted it to work 100% without causing more hassle than it's worth. Link to comment Share on other sites More sharing options...
Recommended Posts