ahmadsajid Posted January 6, 2011 Share Posted January 6, 2011 hi I want to show a simple math in my product page that is markup. so I put this code to the product tpl {math equation="(( x / y ) * 100 )" x=$product.price y=$product.wholesale_price} but its not working can you guys please help me to solve it because of smarty knowledge i am having this issue please help asap. Link to comment Share on other sites More sharing options...
DevNet Posted January 6, 2011 Share Posted January 6, 2011 hi I want to show a simple math in my product page that is markup. so I put this code to the product tpl {math equation="(( x / y ) * 100 )" x=$product.price y=$product.wholesale_price} but its not working can you guys please help me to solve it because of smarty knowledge i am having this issue please help asap. Hi,Your equation is good !Have you got any ouput value over $product.price and $product.wholesale_price ?This value is decimal like : xxx.xx, or xxx,xx ?I found this thread : http://www.smarty.net/forums/viewtopic.php?p=40394&sid=a0109b1c4ea606c65840c7e9961dfaf3Best regards Link to comment Share on other sites More sharing options...
ahmadsajid Posted January 6, 2011 Author Share Posted January 6, 2011 Thanks for reply.my this function works {math equation="(x/y)*100" x=$productPrice y=$product->wholesale_price} but I wanted 2 decimal or round this can you help me? Link to comment Share on other sites More sharing options...
DevNet Posted January 6, 2011 Share Posted January 6, 2011 Thanks for reply.my this function works {math equation="(x/y)*100" x=$productPrice y=$product->wholesale_price} but I wanted 2 decimal or round this can you help me? Try this :{math equation="(x/y)*100" x=$productPrice y=$product->wholesale_price format="%.2f"} Best regards Link to comment Share on other sites More sharing options...
ahmadsajid Posted January 6, 2011 Author Share Posted January 6, 2011 extremely grateful and thanks a lot. it worked!! now i am trying a way round it. but many many thanks to you. Link to comment Share on other sites More sharing options...
ahmadsajid Posted January 6, 2011 Author Share Posted January 6, 2011 well got the solution the code is {math equation="(x/y)*100" x=$productPrice y=$product->wholesale_price format="%.0f"} Thanks for all of your help and time. Link to comment Share on other sites More sharing options...
DevNet Posted January 6, 2011 Share Posted January 6, 2011 extremely grateful and thanks a lot. it worked!! now i am trying a way round it. but many many thanks to you. bye Link to comment Share on other sites More sharing options...
pedro fonseca Posted April 18, 2011 Share Posted April 18, 2011 cool. working.and multiply value combination name "Paint"example product:price: 10wholesale_price: 8value Paint: 0.5how put equation: (10-8)*0.5?$group.name == 'Paint' {math equation="(x-y)" x=$product->getPrice(true, $smarty.const.NULL) y=$product->wholesale_price} Link to comment Share on other sites More sharing options...
HddnTHA Posted May 26, 2014 Share Posted May 26, 2014 Thanks for solution. It's what i need atm. Link to comment Share on other sites More sharing options...
lkanada Posted August 6, 2017 Share Posted August 6, 2017 For 2 decimals you can use: {math equation="(x/y)*100" x=$productPrice y=$product->wholesale_price format="%.2f"} This post solved some problems for me, many thanks Link to comment Share on other sites More sharing options...
Recommended Posts