Author Topic: Display product price without ,00 when it integer [solved]  (Read 1974 times)

d0ublezer0

  • Jr. Member
  • **
  • Posts: 210
Display product price without ,00 when it integer [solved]
« 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?

Jörgen

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3881
    • Kreativ Fotografi
  • VirtueMart Version: 3.4.x
Re: Display product price without ,00 when it integer
« Reply #1 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
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

d0ublezer0

  • Jr. Member
  • **
  • Posts: 210
Re: Display product price without ,00 when it integer
« Reply #2 on: January 12, 2021, 10:48:24 am »
thanks, i used
Code: [Select]
<?= str_replace(",00","",$currency->createPriceDiv('salesPrice', '  itemprop="price" ', $product->prices, false, false, 1.0, true)) ?>

Jörgen

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3881
    • Kreativ Fotografi
  • VirtueMart Version: 3.4.x
Re: Display product price without ,00 when it integer [solved]
« Reply #3 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
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

rdcustom

  • Beginner
  • *
  • Posts: 14
    • RD Custom
Re: Display product price without ,00 when it integer
« Reply #4 on: August 01, 2022, 15:28:47 pm »
thanks, i used
Code: [Select]
<?= 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

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 10510
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.6.8
Re: Display product price without ,00 when it integer [solved]
« Reply #5 on: August 01, 2022, 16:31:19 pm »
what ever file your template uses to display prices .. normally sublayout/prices.php
GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 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
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation