Jump to content

Modifting date in E-Mail Templates


Recommended Posts

Hi All,

 

I am looking to modify the due by date in email templates ($invoice_date_due). I want to subtract 1 day.

 

I have tried doing this with php, however it doesn't look like you can put php into the email templates. (I just get a white screen (Even if i just put {php}{/php}))

 

Bear in mind I don't want to update the due date of an invoice just chnage that date for use inside the email template.

 

This is the code I have tried:

 

{php}

$ccdate = DateTime::createFromFormat('d/m/Y', $this->_tpl_vars["invoice_date_due"]);

$ccdate->modify("plus 1 day");

$this->_tpl_vars["cc_date_due"] = $ccdate->format('d/m/Y');

{/php}

 

Does anyone have any ideas?

 

Thanks,

 

Adam

 

*More info: I need to be able to remove one day from the due date as we attempt to cature credit cards 1 day before due date. This is the line that would change:

 

Payment will be taken automatically on {$invoice_date_due} from your credit card on record with us.

 

So invoice due date might be 13/03/2015 and credit card charge date will be 12/03/2015

Edited by traxwriter
More info
Link to comment
Share on other sites

This should do what you need:

 

{$invoice_date_due|cat:'-1 day'|date_format:"%d/%m/%Y" }

 

Thanks jclarke, This didn't quite work beucase strtotime doesn't work with slashes in the date format, however you helped me figure it out.

 

Here's what worked:

 

{$invoice_date_due|replace:"/":"-"|cat:" -1 day"|date_format:"%d/%m/%Y"}

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