Thread: Adding a Comma
View Single Post
  #4  
Old 04-01-2021, 07:18 PM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,031
 

Default 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
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote