News:

Support the VirtueMart project and become a member

Main Menu

Display product price without ,00 when it integer [solved]

Started by d0ublezer0, January 12, 2021, 09:13:47 AM

Previous topic - Next topic

d0ublezer0

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?

Jörgen

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
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

d0ublezer0

thanks, i used
<?= str_replace(",00","",$currency->createPriceDiv('salesPrice', '  itemprop="price" ', $product->prices, false, false, 1.0, true)) ?>


Jörgen

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
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

rdcustom

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?

GJC Web Design

what ever file your template uses to display prices .. normally sublayout/prices.php
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation