Jump to content

How to add new merge field for {$invoice_url} to emails


Benbodhi

Recommended Posts

Anybody know how I can create a new merge tag {$invoice_url} to be used in invoice email templates that returns just the URL of the invoice in question so I can use the plain text URL in a custom button?

 

I'm currently modifying all of my email templates.

When using the{$invoice_link} merge field, it outputs the entire link, when I only need the plain text url to use in a custom button's markup.

 

I have looked at adding hooks, but the only documentation I can find will replace existing content with custom content... Which could work, but I can't find anywhere in the codebase where the original {$invoice_link} is created to see how it pulls the URL in to that link.

 

Cheers

Link to comment
Share on other sites

create new .php file inside /includes/hooks/ directory, and put the following code inside it

 

<?php

add_hook("EmailPreSend", 1, function($vars){

   global $CONFIG;

   return array("invoice_url" => $CONFIG['SystemURL']."/viewinvoice.php?id".$vars['relid']);

});

 

now in your email templates (Invoice Messages) use the {$invoice_url} to insert URL of invoice

Link to comment
Share on other sites

Anybody know how I can create a new merge tag {$invoice_url} to be used in invoice email templates that returns just the URL of the invoice in question so I can use the plain text URL in a custom button?

 

I'm currently modifying all of my email templates.

When using the{$invoice_link} merge field, it outputs the entire link, when I only need the plain text url to use in a custom button's markup.

if you're editing the templates in the way you describe, then you shouldn't really need a hook if the URL you want already occurs in an existing variable.

so in your email template, you have {$invoice_link} which, let's say, outputs the following code...

 

<a href="http://demo.whmcs.com/viewinvoice.php?id=1">http://demo.whmcs.com/viewinvoice.php?id=1</a>

you could use some Smarty code to obtain just the URL.

 

{$invoice_link|strip_tags:false}

... and you can then go on to use that in your button code, e.g...

 

<input onclick="window.location.href='{$invoice_link|strip_tags:false}'" type="button" value="Invoice Link" />

you should then find that you can add working links to your buttons - however, you decide to show them, e.g input forms, css etc. :idea:

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