tuga Posted August 29, 2022 Share Posted August 29, 2022 (edited) Hi, My credit card provider uses random charge name statements and some clients dispute the payments because they don't recognize them. Long story short, I'd like to insert an external variable on the invoice payment confirmation email. Something like: Request url Get var Insert var on email Is this possible? if so, how can it be done? Thank you. Edited August 29, 2022 by tuga 0 Quote Link to comment Share on other sites More sharing options...
leemahoney3 Posted August 29, 2022 Share Posted August 29, 2022 Hi tuga, This would be possible with the EmailPreSend hook, you can simply merge your additional variable into the relevant email templates. For example, say you wanted to add the variable $myCoolVariable, open email templates in WHMCS by going to System Settings > Email Templates and edit the following templates: Invoice Payment Confirmation Credit Card Payment Confirmation Add the variable to the templates above in the format {$myCoolVariable} Then create a new file in your /includes/hooks/ folder (e.g. addCustomVariableToInvoiceConfirmationEmail.php) with the following code: <?php function add_custom_variable_to_invoice_confirmation_email($vars) { $templates = [ 'Credit Card Payment Confirmation', 'Invoice Payment Confirmation' ]; $messageName = $vars['messagename']; $merge_fields = []; if (in_array($messageName, $templates)) { $merge_fields['myCoolVariable'] = 'This is my awesome and really cool variable!'; } return $merge_fields; } add_hook('EmailPreSend', 1, 'add_custom_variable_to_invoice_confirmation_email'); 2 Quote Link to comment Share on other sites More sharing options...
tuga Posted August 31, 2022 Author Share Posted August 31, 2022 Hi Lee, I'll give it a try and post the results asap. Thank you very much. 0 Quote Link to comment Share on other sites More sharing options...
tuga Posted August 31, 2022 Author Share Posted August 31, 2022 Your code worked flawlessly 👌 thank you so much. 0 Quote Link to comment Share on other sites More sharing options...
leemahoney3 Posted August 31, 2022 Share Posted August 31, 2022 2 hours ago, tuga said: Your code worked flawlessly 👌 thank you so much. Delighted to hear that! 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.