Jump to content

Email Template PHP Code - HTML Tags


smallbx

Recommended Posts

Hi !!

 

I am trying to customize email template "Order Confirmation". I did not want to send customer fields as displayed by default {order_details}.

 

Following is the code I wrote. It works fine, it just the out put which goes in one line without formating.

 

Code:

{php}

$ordernumber = $this->_tpl_vars["order_number"];

$sel_orders = "select id,packageid,billingcycle,domain,amount from tblhosting where orderid = (select id from tblorders where ordernum = ".$ordernumber.")";

 

$productind = 0;

 

echo 'ORDER NUMBER: '.$ordernumber;

$res_orders = mysql_query($sel_orders);

while($rec_orders = mysql_fetch_array($res_orders))

{

echo '<br><br>Product Details<br>';

$sel_products = "select * from tblproducts where id = ".$rec_orders['packageid'];

$res_products = mysql_query($sel_products);

$rec_products = mysql_fetch_array($res_products);

echo 'Product/Service:'.$rec_products['name']."<br>";

echo 'Domain:'.$rec_orders['domain']."<br>";

echo 'Setup Fee:'.$rec_products['msetupfee']."<br>";

echo 'Recurring Amount:'.$rec_orders['amount']."<br>";

echo 'Billing Cycle:'.$rec_orders['billingcycle']."<br><br>";

 

$sel_addons = "select id,name,setupfee,recurring,billingcycle from tblhostingaddons where orderid = (select id from tblorders where ordernum = ".$ordernumber.")";

$res_addons = mysql_query($sel_addons);

 

echo '<strong>Addon Detials</strong><br><br>';

$addcount = 0;

while($rec_addons = mysql_fetch_array($res_addons))

{

$addcount++;

echo 'Addon Name: '.$rec_addons['name'].'<br>';

echo 'Setup Fee: '.$rec_addons['setupfee'].'<br>';

echo 'Recurring Amount: '.$rec_addons['recurring'].'<br>';

echo 'Billing Cycle: '.$rec_addons['billingcycle'].'<br><br>';

}

}

{/php}

 

The output looks like....

 

ORDER NUMBER: 2984937321Product DetailsProduct/Service:Gold PackageDomain:confirmtest.inSetup Fee:299.00Recurring Amount:49.00Billing Cycle:Monthly<strong>Addon Detials</strong>Addon Name: ForumSetup Fee: 199.00Recurring Amount: 0.00Billing Cycle: One Time

 

Question: How do I introduce HTML formating tags in the php code above, such that the output is well structured? (I do not understand Smarty very well.

Link to comment
Share on other sites

Example of a couple of lines

echo 'Product/Service:'.$rec_products['name']."\n";

echo 'Domain:'.$rec_orders['domain']."\n";

echo 'Setup Fee:'.$rec_products['msetupfee']."\n";

echo 'Recurring Amount:'.$rec_orders['amount']."\n";

echo 'Billing Cycle:'.$rec_orders['billingcycle']."\n\n";

Link to comment
Share on other sites

  • 3 weeks later...

Hi I need help with something really easy related to this topic ( I think ) , I am customizing my Confirmation Order Email, the thing is how can I multiply the $invoice_total variable on the email template with something I coded that is inside php tags ?

 

{PHP} $newtotal = $myvariable * $invoice_total {/PHP}

 

And viceversa ?

Link to comment
Share on other sites

Thanks for your response Sparky but it does not work my variable does not responds on the email template.

 

{php}$myFile = "http://www.mydomain/conversion/xchange.php";$fh = fopen($myFile, 'r');$theData = fgets($fh);fclose($fh);$cuentap = ($theData);$tot = number_format($cuentap,2, '.', '');echo $tot;{/php}

 

(${math equation="x / y" x=$invoice_total|regex_replace:"/[uSD$ ]/":"" y=$tot format="%.2f"} MEX)

 

 

 

If I substitute y=$tot with a number lets say y=2 it works but not with $tot , the php is working cause I see the variable by placing inside the php tags , echo $tot, I just do not know how to make work my variable $tot outside the php tags.

 

 

 

 

 

Thanks for your quick responses... Thanks for your help

Link to comment
Share on other sites

You got $tot from the {php} section, you need to assign that variable so that the smarty math function knows what $tot is. so it would go something like this

 

{php}

$myFile = "http://www.mydomain/conversion/xchange.php";

$fh = fopen($myFile, 'r');

$theData = fgets($fh);

fclose($fh);

$cuentap = ($theData);

$tot = number_format($cuentap,2, '.', '');

echo $tot;

$this->assign('tot',$tot);

{/php}

 

(${math equation="x / y" x=$invoice_total|regex_replace:"/[uSD$ ]/":"" y=$tot format="%.2f"} MEX)

Link to comment
Share on other sites

is it possible to make it work using html mode ?

You must enclose {php}...{/php} inside html comments (with HTML Source Editor) to avoid that wysiwyg editor codes '>' to > and if you want comment <!-- and --> with smarty comment and you will see in wysiwyg editor where the code is. And example:

{* <!-- *} {php}$value = 'foo'; $this->assign('smartyvar', $value);{/php} {* --> *}

 

is it possible to do something similar on the pdf invoice ? Does it works similar ?

For pdf invoice you must write native php code (not embedded php in smarty code) in the file includes/pdfconfig.php and you can accomplish something similar.

 

Hope this help.

Link to comment
Share on other sites

  • 3 months later...
You must enclose {php}...{/php} inside html comments (with HTML Source Editor) to avoid that wysiwyg editor codes '>' to > and if you want comment <!-- and --> with smarty comment and you will see in wysiwyg editor where the code is. And example:

{* <!-- *} {php}$value = 'foo'; $this->assign('smartyvar', $value);{/php} {* --> *}

 

 

For pdf invoice you must write native php code (not embedded php in smarty code) in the file includes/pdfconfig.php and you can accomplish something similar.

 

Hope this help.

 

I can't seem to get this to work.

 

In the HTML view source we have:

<!-- {php}$value = 'foo'; $this->assign('test', $value);{/php} -->

Link to comment
Share on other sites

  • 2 months later...

I had some openx invocation code and tried to use:

{fetch file='/templates/portal/openx-strikehawk.html'}

openx-strikehawk.html is

 

<!--/* OpenX Javascript Tag v2.8.1 */-->

<script type='text/javascript'><!--//<![CDATA[
  document.MAX_ct0 ='INSERT_CLICKURL_HERE';

  var m3_u = (location.protocol=='https:'?'https://www.oscommerceuniversity.com/adserver/www/delivery/ajs.php':'http://www.oscommerceuniversity.com/adserver/www/delivery/ajs.php');
  var m3_r = Math.floor(Math.random()*99999999999);
  if (!document.MAX_used) document.MAX_used = ',';
  document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
  document.write ("?zoneid=3&target=_blank");
  document.write ('&cb=' + m3_r);
  if (document.MAX_used != ',') document.write ("&exclude=" + document.MAX_used);
  document.write (document.charset ? '&charset='+document.charset : (document.characterSet ? '&charset='+document.characterSet : ''));
  document.write ("&loc=" + escape(window.location));
  if (document.referrer) document.write ("&referer=" + escape(document.referrer));
  if (document.context) document.write ("&context=" + escape(document.context));
  if ((typeof(document.MAX_ct0) != 'undefined') && (document.MAX_ct0.substring(0,4) == 'http')) {
      document.write ("&ct0=" + escape(document.MAX_ct0));
  }
  if (document.mmm_fo) document.write ("&mmm_fo=1");
  document.write ("'><\/scr"+"ipt>");
//]]>--></script><noscript><a href='http://www.oscommerceuniversity.com/adserver/www/delivery/ck.php?n=acc55927&cb=INSERT_RANDOM_NUMBER_HERE' target='_blank'><img src='http://www.oscommerceuniversity.com/adserver/www/delivery/avw.php?zoneid=3&cb=INSERT_RANDOM_NUMBER_HERE&n=acc55927&ct0=INSERT_CLICKURL_HERE' border='0' alt='' /></a></noscript>

Link to comment
Share on other sites

  • 3 months later...
  • 5 months later...

ppw Thank You! I had a totally different issue altogether. I simply wanted to use

<?php echo date('Y'); ?>

 

in the footer.tpl file, and the year was not showing up. I looked everywhere but could not find an answer (& although this thread link was top in Google's results, I overlooked it a dozen times before checking it out!) Anyway, I used your suggestion and with the below, it works!

 

{php} echo date('Y'); {/php}

Learn something new every day :)

 

Thanks!

Tracy

 

 

You must enclose {php}...{/php} inside html comments (with HTML Source Editor) to avoid that wysiwyg editor codes '>' to > and if you want comment <!-- and --> with smarty comment and you will see in wysiwyg editor where the code is. And example:

{* <!-- *} {php}$value = 'foo'; $this->assign('smartyvar', $value);{/php} {* --> *}

 

 

For pdf invoice you must write native php code (not embedded php in smarty code) in the file includes/pdfconfig.php and you can accomplish something similar.

 

Hope this help.

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