put currency sign in front and change numbers to integer

How to configure and adapt Aimeos based shops as developer
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
S0l
Posts: 8
Joined: 22 Nov 2020, 15:15

put currency sign in front and change numbers to integer

Post by S0l » 22 Nov 2020, 16:07

Hello,
We are using Aimeos version 20.10.1 on a Typo3 v.9.5.21 with php 7.3.19-1~deb10u1 and managed to put some products in. However, for the currency we are using (Chilean Peso) it is required that the currency nominator "$" is in front of the price instead behind the price. Also, we would like to eradicate the decimals and only put the price in integers.

Right now, a price for a product is shown like this: 3.500,00 $
We would like the price be shown like this: $ 3.500

How could we achieve this?

We have found some old questions:
post3191.html#p3191
help-f15/price-format-t3221.html

, but cannot figure out where Locale.php is located in typo3conf/ext/aimeos in order to change at least the decimals from 2 to zero.

Also how to change the currency sign from behind the price numbers to in front of the price numbers provides a challenge for us.

Any hint appreciated.
aimeos 20.10.4 with aimeos_dist 20.10.1 on Typo3 10.4.12 with php 7.3.19-1 ~ deb10u1

User avatar
aimeos
Administrator
Posts: 7835
Joined: 01 Jan 1970, 00:00

Re: put currency sign in front and change numbers to integer

Post by aimeos » 23 Nov 2020, 17:43

The precision of the price values can be changed using "mshop/price/precision", i.e.:

Code: Select all

plugin.tx_aimeos.settings.mshop.price.precision = 0
The format of the prices is determined by a string that can be translated:
https://aimeos.org/docs/latest/typo3/cu ... anslations

Here's the code that makes the translation:
https://github.com/aimeos/ai-client-htm ... rd.php#L55

Use client as translation domain %1$s %2$s as string and %2$s %1$s as translation. Then, the currency sign and value is swapped.

Make sure you add this also to the scheduler tasks so it will be used for the sent emails too
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

S0l
Posts: 8
Joined: 22 Nov 2020, 15:15

Re: put currency sign in front and change numbers to integer

Post by S0l » 24 Nov 2020, 04:51

Thank you very much for the swift answer. I have changed the decimals to 0 adding this to my templates TypoScript Setup:

Code: Select all

 # set the precision of price values to integer values using mshop.price.precision
plugin.tx_aimeos.settings.mshop.price.precision = 0 
But when I add the following, there is no change to the order as we want it ( currency first, price second) Could someone point out my error? The template analyzer did not show any abnormalities...

Code: Select all

# swapping the currency sign with the price value
plugin.tx_aimeos.settings.i18n.es.0 {
    domain = client
    string = %1$s %2$s
    trans = %2$s %1$s
}
Have a good day!
aimeos 20.10.4 with aimeos_dist 20.10.1 on Typo3 10.4.12 with php 7.3.19-1 ~ deb10u1

User avatar
aimeos
Administrator
Posts: 7835
Joined: 01 Jan 1970, 00:00

Re: put currency sign in front and change numbers to integer

Post by aimeos » 25 Nov 2020, 09:48

S0l wrote: 24 Nov 2020, 04:51 But when I add the following, there is no change to the order as we want it ( currency first, price second) Could someone point out my error? The template analyzer did not show any abnormalities...
Can you try this instead:

Code: Select all

plugin.tx_aimeos.settings.i18n.es.0 {
    domain = client/code
    string = price:default
    trans = %2$s %1$s
}
This is the second option for translating price formats:
https://github.com/aimeos/ai-client-htm ... rd.php#L55
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

S0l
Posts: 8
Joined: 22 Nov 2020, 15:15

Re: put currency sign in front and change numbers to integer

Post by S0l » 25 Nov 2020, 18:29

:D :D :D Brilliant!
Success! Yes, this did the trick. I added the same snippet to our scheduler tasks. Thank you for your support!
aimeos 20.10.4 with aimeos_dist 20.10.1 on Typo3 10.4.12 with php 7.3.19-1 ~ deb10u1

Post Reply