Jump to content

How to remove custom fields from email template


John

Recommended Posts

My Order Confirmation email template contains a variable {$order_details} which contains all the details about the order. Due to these all being bulked together I can't change any of them. I have multiple product custom fields, of which one is a product password, which i really don't want to send in plain text via email to the customer ... for obvious reasons.

After looking through the documentation i discovered EmailPreSend hook, but i have no idea how to remove my custom field using this hook, as I don't know what the variable names/arrays are. I experimented a little, all resulting in an "OOPS" page showing me i have no idea what i am doing lol.

Any idea how to remove this product custom field from my order confirmation email? Any help in pointing me in the right direction would be greatly appreciated. Also, this is my first time here, so I didn't know if coding/hook questions go here or not.

-John

Link to comment
Share on other sites

Hi John,

you could do it in the template using Smarty...

so let's say one of the customfields is called "Password", we can remove all customfields by doing this...

{foreach from=$ordersplit item=keyword}
{if $keyword|strstr:"Password"}
{$keyword|strstr:'First'}<br />
{elseif $keyword neq "\n"}
{$keyword|strstr:':':true}: {$keyword|strstr:':':false|replace:': ':''}<br />
{else}
<br />
{/if}
{/foreach}

any products that don't have a password customfield will continue to show all customfields - so if you wanted to hide all customfields, you'd need to expand that initial {if} statement to include one CF from each product (you don't need to add them all, just one from each (or less if multiple products use the same CF names).

also, note what I said in the above thread about the Smarty Security Policy - that's important as it won't work unless you make those changes (if you're using v7+). :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