X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (X-Cart 5) (https://forum.x-cart.com/forumdisplay.php?f=56)
-   -   Adding a Comma (https://forum.x-cart.com/showthread.php?t=78200)

Blainevk 04-01-2021 10:32 AM

Adding a Comma
1 Attachment(s)
Hello X-cart 5 Community,

I want to add a comma to a number that I created from the Price of all items in my Mall. See image below for detailed description...

Thanks in advance for your help,

cflsystems 04-01-2021 11:25 AM

Re: Adding a Comma
You can use the PHP format_number


If it doesn't work directly in the twig file set new method to use it and return the formatted value

Blainevk 04-01-2021 02:33 PM

Re: Adding a Comma
Thanks Steve,

But this is all GREEK to me, how much would you charge me to make this work?

cflsystems 04-01-2021 07:18 PM

Re: Adding a Comma
You just have to do what you already did but use the format_number function.
Where you added {{ (this.getListPrice() * 1000) +0 }} replace it with

{{ format_number($this.getListPrice() * 1000) }}

The function uses as default 0 decimals, dot as decimal separator and comma as thousands separator so the above will effectively return

123,450 (if list price is say $123.45)

Doing this with php method to use in the twig file will require you to have custom module and define the method to use which will essentially do the same.
I can code this for you if you want to but I just don't see the need for it when you can replace it within the template with the code I provided here, just like you already did with your own version.

However if you don't feel like doing this or want to expand on it you can contact me with details and I can get it done for you. Just open a ticket at support.cflsystems.com

All times are GMT -8. The time now is 10:25 AM.

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