Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Template syntax - maths operators

Quote Reply
Template syntax - maths operators
Hi,

I have just been reading the GT::Template syntax guide for Links SQL and I am a little stuck on the math operators.

I am trying to show 5% less of varaiable 'cost' to 2 decimal places. Cost is a numerical variable.

i.e. <%cost%> is the normal product cost but I want to add a second value below it as a sale price, hence why I would like Links SQL to calculate the 5% dicount automatically.

Hope that makes sense.

Regards

Alex



Indigo Clothing is a t-shirt printing company based in the UK.
Indigo Clothing | Promotional Clothing | T-Shirt Printing | Embroidery
Quote Reply
Re: [IndigoClothing] Template syntax - maths operators In reply to
Please - can anyone help? Frown



Indigo Clothing is a t-shirt printing company based in the UK.
Indigo Clothing | Promotional Clothing | T-Shirt Printing | Embroidery
Quote Reply
Re: [IndigoClothing] Template syntax - maths operators In reply to
Maybe something like this?

<%Discount($Cost)%>

Code:
sub {

my $cost = $_[0];
my $percentage = sprintf ("%0.2f",$cost / 100 * 95);
return $percentage;

}

Unsure

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!