VirtueMart Forum

VirtueMart 2 + 3 + 4 => Product pricing => Topic started by: d0ublezer0 on January 12, 2021, 09:13:47 AM

Title: Display product price without ,00 when it integer [solved]
Post by: d0ublezer0 on January 12, 2021, 09:13:47 AM
Some prices set as integer value, some - as float.

i want to display integer values without decimals, decimals is redundant for them.
but, float price values must be displayed with decimals.

https://prnt.sc/wllthf

it is possible?
Title: Re: Display product price without ,00 when it integer
Post by: Jörgen on January 12, 2021, 09:32:49 AM
In your example both are float values, the one You call integer just happens to have the (rounded) decimal part == 0.

You have to make some kind of php snippet that checks if the price does not have a decimal part == 0 and display with zero decimals. This would probably be done in prices.php of your template, if I remember correctly.

Jörgen @ Kreativ Fotografi
Title: Re: Display product price without ,00 when it integer
Post by: d0ublezer0 on January 12, 2021, 10:48:24 AM
thanks, i used
<?= str_replace(",00","",$currency->createPriceDiv('salesPrice', '  itemprop="price" ', $product->prices, false, false, 1.0, true)) ?>

Title: Re: Display product price without ,00 when it integer [solved]
Post by: Jörgen on January 12, 2021, 20:58:18 PM
Thanks for returning, this is a useful solution. There may be more efficient ones. But I appreciate the simplicity.
I will mark this as solved

Jörgen @ Kreativ Fotografi
Title: Re: Display product price without ,00 when it integer
Post by: rdcustom on August 01, 2022, 15:28:47 PM
Quote from: d0ublezer0 on January 12, 2021, 10:48:24 AM
thanks, i used
<?= str_replace(",00","",$currency->createPriceDiv('salesPrice', '  itemprop="price" ', $product->prices, false, false, 1.0, true)) ?>

where did you set this? and in which file?
Title: Re: Display product price without ,00 when it integer [solved]
Post by: GJC Web Design on August 01, 2022, 16:31:19 PM
what ever file your template uses to display prices .. normally sublayout/prices.php