Jump to content

[Solved] Display system currency


MeRuud

Recommended Posts

Hi all,

 

I am working on a module and I am trying to display the (current) currency symbol.

I just started with Prestashop and this is my first module. Documentation is fairly limited and unorganized so it is not helping my search.

 

I have tried:

 

- $currency (nothing shows up)

- $currencies (a 1 shows up)

- PS_CURRENCY_DEFAULT (displays a 2, ID of current currency)

 

All I am trying to achieve is when the visitor is supposed to see a $, it will show a $ and if the visitor is supposed to see the euro it shows a euro sign.

 

Thanks in advanced, I appreciate your help.

Ruud

Edited by MeRuud (see edit history)
Link to comment
Share on other sites

Sorry my bad.

 

Basically when I was facing the issue above I used the {math} function (smarty) to calculate the price that I needed, this will result in the price without the currency symbol.

 

For example:

$productPrice = $10
$quantity_discount.quantity = 2

{math equation="x + y" x=$productPrice y=$quantity_discount.quantity}

Will result in:
12

 

I didn't know you could use math equation without using the above function. But Prestashop supports the direct use of match symbols on smarty variables without using the {math} function.

 

For example:


$productPrice = $10
$quantity_discount.quantity = 2

{convertPrice price=($productPrice+$quantity_discount.quantity)|floatval}


Will result in:
$12

 

Another benefit of not using the {math} function directly is that the {math} function is an expensive function in performance due to its use of the php eval() function. Doing the math in PHP is much more efficient, so whenever possible do the math calculations in the script and assign() the results to the template.

 

Read more on the {math} function here:

http://www.smarty.net/docsv2/en/language.function.math.tpl

 

Hope this helps,

Ruud

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...