View Single Post
  #2  
Old 05-17-2004, 04:50 AM
 
jeremye jeremye is offline
 

Senior Member
  
Join Date: Apr 2004
Location: Philadelphia, PA
Posts: 158
 

Default

You actually need to use the math function within Smarty to calculate this value:

Code:
{math equation="(sub_total+discount+shipping_cost)*0.02" sub_total=$cart.sub_total discount=$cart.discount shipping_cost=$cart.shipping_cost assign="surcharge" format="%.2f"}

Note how you have to reference smarty variables within the equation (sub_total=$cart.sub_total).

Notice the "assign" variable is 'surcharge'. So you can then display the surcharge in the template as {$surcharge}.

The format=%.2f will output the surcharge as "1.22" or "1.00".

NOTE: Be very careful with using the MATH function. It is very inefficient and will cause your pages to load slowly if used in multiple loops. Try to use PHP for that if this is intended for looping.

Let me know if this works or not, since I haven't actually tested this.
__________________
Jeremy
X-Cart Gold v3.4.14 [Linux/Apache]
Heavily Modded
Reply With Quote