smallbx Posted January 14, 2009 Share Posted January 14, 2009 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. 0 Quote Link to comment Share on other sites More sharing options...
sparky Posted January 15, 2009 Share Posted January 15, 2009 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"; 0 Quote Link to comment Share on other sites More sharing options...
buddy Posted February 5, 2009 Share Posted February 5, 2009 Hi smallbx, can you help me to customize upgrade order email also? It use the same template right? Thank you! 0 Quote Link to comment Share on other sites More sharing options...
davoram Posted February 6, 2009 Share Posted February 6, 2009 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 ? 0 Quote Link to comment Share on other sites More sharing options...
davoram Posted February 6, 2009 Share Posted February 6, 2009 I think this is better explain... Example {PHP} $myvariable {/PHP} $newtotal = $myvariable * $invoice_total It seems that my variable is not recognize outside my php tags ... hope someone can help me 0 Quote Link to comment Share on other sites More sharing options...
sparky Posted February 6, 2009 Share Posted February 6, 2009 Take a look here... it may put you on the right track http://smarty.net/manual/en/language.function.math.php 0 Quote Link to comment Share on other sites More sharing options...
davoram Posted February 7, 2009 Share Posted February 7, 2009 Thanks Sparky I read it but do not get it , if someone can put an example I will appreciated a lot 0 Quote Link to comment Share on other sites More sharing options...
sparky Posted February 7, 2009 Share Posted February 7, 2009 {math equation="x * y" x=$myvariable y=$invoice_total} That will output the answer to $myvariable x $invoice_total 0 Quote Link to comment Share on other sites More sharing options...
davoram Posted February 7, 2009 Share Posted February 7, 2009 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 0 Quote Link to comment Share on other sites More sharing options...
sparky Posted February 7, 2009 Share Posted February 7, 2009 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) 0 Quote Link to comment Share on other sites More sharing options...
davoram Posted February 7, 2009 Share Posted February 7, 2009 It is working now the mayor problem was that the email was on html I have to switch it to plain text so the code can work, is it possible to make it work using html mode ? Thanks 0 Quote Link to comment Share on other sites More sharing options...
davoram Posted February 8, 2009 Share Posted February 8, 2009 Hi, is it possible to do something similar on the pdf invoice ? Does it works similar ? 0 Quote Link to comment Share on other sites More sharing options...
ppw Posted February 9, 2009 Share Posted February 9, 2009 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. 0 Quote Link to comment Share on other sites More sharing options...
atDev Posted May 16, 2009 Share Posted May 16, 2009 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} --> 0 Quote Link to comment Share on other sites More sharing options...
sparky Posted May 16, 2009 Share Posted May 16, 2009 remove the comment from around it <!-- --> {php}$value = 'foo'; $this->assign('test', $value);{/php} 0 Quote Link to comment Share on other sites More sharing options...
atDev Posted May 16, 2009 Share Posted May 16, 2009 I tried this as well. The email never gets sent. As soon as I remove that line the email comes through fine. This is using the SendEmail API. 0 Quote Link to comment Share on other sites More sharing options...
sparky Posted May 16, 2009 Share Posted May 16, 2009 try it as a smarty tag {assign var=test value="foo"} then to display it {$test} 0 Quote Link to comment Share on other sites More sharing options...
atDev Posted May 16, 2009 Share Posted May 16, 2009 Got it to work, thanks. Was unrelated typo causing the error, sorry. 0 Quote Link to comment Share on other sites More sharing options...
atDev Posted May 16, 2009 Share Posted May 16, 2009 Ok works now, was unrelated, sorry. 0 Quote Link to comment Share on other sites More sharing options...
Inetbiz Posted August 13, 2009 Share Posted August 13, 2009 Does the smarty {fetch} command work, perhaps? 0 Quote Link to comment Share on other sites More sharing options...
Inetbiz Posted August 13, 2009 Share Posted August 13, 2009 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> 0 Quote Link to comment Share on other sites More sharing options...
Inetbiz Posted December 3, 2009 Share Posted December 3, 2009 Can someone post an example openx invocation snip? 0 Quote Link to comment Share on other sites More sharing options...
flipflopmedia Posted May 27, 2010 Share Posted May 27, 2010 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. 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.