Closed (fixed)
Project:
Ubercart
Version:
7.x-3.x-dev
Component:
Products
Priority:
Minor
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
22 Feb 2013 at 07:28 UTC
Updated:
16 Jan 2015 at 23:06 UTC
Jump to comment: Most recent
Comments
Comment #1
tr commentedYou can do this by overriding theme_uc_price().
Comment #2
philsward commentedI don't even know what that means? I don't know how to override anything in the code. I don't code...
Comment #3
DanZ commentedThe display of almost everything in Drupal is controlled by themes. See https://drupal.org/documentation/theme for an explanation.
A theme function is a bit of PHP code that takes data and outputs HTML to display on a browser. A theme template does the same thing, except in a file, not a function. So, yes. Overriding these things requires some programming. If you can't program, that's OK. People who can program are pretty easy to find.
theme_uc_price() is the built-in function that themes prices. It uses uc_currency_format() to actually build the number string.
See Overriding themable output for directions on how to override that theme function. You'll want something that removes the decimal point if the price is close enough to an even dollar.
Or...you could try going to admin/store/settings/store, clicking on the "Currency format" vertical tab, and setting the "Number of decimal places" to zero.
Comment #4
philsward commented@DanZ Thanks for the general directions. For anyone else looking to do this:
(replace theme_uc_price with the name of your theme... ex. bartik_uc_price)
Works with panels too. Does NOT work with Views when "Display Price -> Format" is set to "Ubercart price". You have to set the format to "Numeric" to have views strip the .00. Bug maybe? If a views price format is set to "Ubercart Price" shouldn't it honor an overridden theme_uc_price?
Comment #5
philsward commented@DanZ Forgot to mention you can disable the decimal, but it doesn't disable it gracefully. Meaning, if you have a number with change ($9.92) it gets rid of the .92 which isn't exactly ideal :-/
Comment #7
haysuess commentedThe solution in #4 works for me, but ONLY in Views. When I print the price within my node template, I still get prices like $29.00.
Any ideas?