X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Arithmetic operators produce no result with variables (https://forum.x-cart.com/showthread.php?t=4654)

e_gregious 10-07-2003 05:06 AM

Arithmetic operators produce no result with variables
 
I am trying to re-format the invoice/order email and am using a html table to contrl the layout.
When I try to get a line total, however, I cannot get the product of the qty and price variables.
My code at the moment:
<td width=15%><font face="Arial" size=2>({$products[prod_num].price} * {$products[prod_num].amount})</font></td>

This produces a result like:
(14.95 * 10) instead of the desired result 149.50

I have tried many variations on the PHP syntax but can't get anything to work. Enclosing this formula with <? ... ?> only yields a blank.
What am I missing?
Would greatly appreciate some help.
Thanks
Greg

Mad 10-07-2003 06:24 PM

<td width=15%><font face="Arial" size=2>({math equation="x * y" x=$products[prod_num].price y=$products[prod_num].amount format="%.2f"})</font></td>

That should do it. "format="%.2f"" simply keeps the decimel places to two, in case you were wondering.

So output should be 149.50.

e_gregious 10-08-2003 12:27 AM

MAD, your blood's worth bottling!!!
Worked a treat - thanks heaps.
:D


All times are GMT -8. The time now is 11:34 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.