Forums / Setting Up Categories, Products, Attributes / Remove Decimal from Attribute Prices?

Remove Decimal from Attribute Prices?

Views: 3,851

Results 1 to 12 of 12
6 May 2011, 2:13 PM
#1
swamyg1 avatar

swamyg1

Zen Follower

Join Date:
Dec 2008
Location:
San Fran
Posts:
382
Plugin Contributions:
0

Remove Decimal from Attribute Prices?

Hi There,

I'd like to remove the .00 decimal from my attribute prices so my prices read like $7, instead of $7.00. This will save me 10px or so!

Can anyone point me in the right direction?

6 May 2011, 2:19 PM
#2
haredo avatar

haredo

Totally Zenned

Join Date:
Apr 2006
Location:
Texas
Posts:
6,185
Plugin Contributions:
0

Re: Remove Decimal from Attribute Prices?

admin panel/ localization / currencies

Select your currency then click Edit. In Decimal Places field change 2 to 0.

But i believe this will change the main price also.. :lookaroun

Need a hand with Zen Cart? Hire the team at myZenCartZone.com for upgrades, repairs, and custom plugins.

Zen Cart Certified hosting at myZenCartHost.com.

6 May 2011, 2:24 PM
#3
swamyg1 avatar

swamyg1

Zen Follower

Join Date:
Dec 2008
Location:
San Fran
Posts:
382
Plugin Contributions:
0

Re: Remove Decimal from Attribute Prices?

Yes, I did know about that actually. Thank you.

I had done that months ago but then changed it back for marketing reasons. Although it simplifies the pricing structure I wasn't crazy about the effect it might have on consumers.

I was mainly looking for a way to do this with just attributes, don't know if it's possible.

31 Jul 2011, 9:28 PM
#4
alexun avatar

alexun

New Zenner

Join Date:
Jul 2011
Posts:
2
Plugin Contributions:
0

Re: Remove Decimal from Attribute Prices?

Hi,

I do not know if this is useful to you anymore but i found you can edit de number of decimals applied to your attribute price directly in the data base table (i used PhpMyAdmin but i assume you can use any database management program, ) you need to modify the "products_attributes" table on your data base change the type to "decimal(15,0)" in the “options_values_price” field.

The second number is the number of decimals you want to use, the default setting is "decimal(15,4)"

Hope it helps.

Alejandro Guzmán

18 Apr 2012, 4:03 PM
#5
djdavedawson avatar

djdavedawson

Zen Follower

Join Date:
Jul 2005
Location:
Orlando, Fl
Posts:
343
Plugin Contributions:
0

Re: Remove Decimal from Attribute Prices?

I'd like to remove the .00 decimal from my attribute prices so my prices read like $7, instead of $7.00. This will save me 10px or so!

Goto file -> tpl_modules_attributes.php

Around Line 32

Replace this:

<div class="back"><?php echo "\n" . $options_menu[$i]; ?></div>

With this:

<div class="back"><?php echo "\n" . str_replace('.00','',$options_menu[$i]); ?></div>

Hope this helps

~D

16 Oct 2012, 4:58 AM
#6
swamyg1 avatar

swamyg1

Zen Follower

Join Date:
Dec 2008
Location:
San Fran
Posts:
382
Plugin Contributions:
0

Re: Remove Decimal from Attribute Prices?

djdavedawson:

Goto file -> tpl_modules_attributes.php

Around Line 32

Replace this:

<div class="back"><?php echo "\n" . $options_menu[$i]; ?></div> ``` > > With this: > ```php <div class="back"><?php echo "\n" . str_replace('.00','',$options_menu[$i]); ?></div> ``` > > Hope this helps > > ~D

It does help! Any idea how to use it on product pages?

16 Oct 2012, 1:57 PM
#7
djdavedawson avatar

djdavedawson

Zen Follower

Join Date:
Jul 2005
Location:
Orlando, Fl
Posts:
343
Plugin Contributions:
0

Re: Remove Decimal from Attribute Prices?

admin panel/ localization / currencies

Select your currency then click Edit. In Decimal Places field change 2 to 0.

But i believe this will change the main price also..

I have not tested this but haredo's quote above says it should change both.

16 Oct 2012, 2:31 PM
#8
swamyg1 avatar

swamyg1

Zen Follower

Join Date:
Dec 2008
Location:
San Fran
Posts:
382
Plugin Contributions:
0

Re: Remove Decimal from Attribute Prices?

djdavedawson:

I have not tested this but haredo's quote above says it should change both.

The only probem with this method is that when we have a percentage off sale, we need to display the change in order to display accurate information to the customer... On the checkout page at least. Adjusting this through the admin seems to only change the display, but the recorded numbers do display the change in decimals.

I tested this, if a $39 product is 15% off the cost becomes $33.15. This is the amount that is actually charged to the customer, so I need to show this to the customer on the checkout page and shopping cart pages.

Hiding the .00 on product pages and listing pages is all I really need to do. That's why I thought this php code would work but I can't figure out how to use it on product and listing pages.

<div class="back"><?php echo "\n" . str_replace('.00','',$options_menu[$i]); ?></div>
16 Oct 2012, 2:39 PM
#9
djdavedawson avatar

djdavedawson

Zen Follower

Join Date:
Jul 2005
Location:
Orlando, Fl
Posts:
343
Plugin Contributions:
0

Re: Remove Decimal from Attribute Prices?

Can you share a link to your site? You can PM if you like

16 Oct 2012, 4:17 PM
#10
djdavedawson avatar

djdavedawson

Zen Follower

Join Date:
Jul 2005
Location:
Orlando, Fl
Posts:
343
Plugin Contributions:
0

Re: Remove Decimal from Attribute Prices?

Ok, so the first thing to understand is how the prices show up in zen cart.

They are displayed by a function called "zen_get_products_display_price".

This function is located in the following file -> includes/functions/functions_prices.php around line 149.

One solution would be to change the following around line 286 from this:

return $final_display_price . $free_tag . $call_tag;

to this:

return str_replace('.00','',$final_display_price) . $free_tag . $call_tag;

This will get rid of the .00 but leave the .15 in the sale price.

That being said, it is never the best idea to modify core functions.

The function may be used somewhere else in the script that might affect something untested.

The better solution would be NOT to modify the function and use this from above.

admin panel/ localization / currencies

Select your currency then click Edit. In Decimal Places field change 2 to 0.

But instead of using percentages to discount your items, adjust the sale values to .00

In your example 33.15, would become 33.00, the percentage off should still remain 15%

16 Oct 2012, 11:27 PM
#11
swamyg1 avatar

swamyg1

Zen Follower

Join Date:
Dec 2008
Location:
San Fran
Posts:
382
Plugin Contributions:
0

Re: Remove Decimal from Attribute Prices?

djdavedawson:

Ok, so the first thing to understand is how the prices show up in zen cart.

They are displayed by a function called "zen_get_products_display_price".

This function is located in the following file -> includes/functions/functions_prices.php around line 149.

One solution would be to change the following around line 286 from this:

return $final_display_price . $free_tag . $call_tag;

> 
> to this:
> 
> ```php
return str_replace('.00','',$final_display_price) . $free_tag . $call_tag;

This will get rid of the .00 but leave the .15 in the sale price.

That being said, it is never the best idea to modify core functions.

The function may be used somewhere else in the script that might affect something untested.

The better solution would be NOT to modify the function and use this from above.

But instead of using percentages to discount your items, adjust the sale values to .00

In your example 33.15, would become 33.00, the percentage off should still remain 15%

Thank you for your help with this. This seems to do what I've been trying to achieve. However, I do agree it's best to not modify the core functions.

Can you tell me what you mean by "But instead of using percentages to discount your items, adjust the sale values to .00"... I'm just not getting that. How exactly would I adjust the sales value to .00? Sorry if that's a dumb question?

17 Oct 2012, 3:08 AM
#12
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Remove Decimal from Attribute Prices?

swamyg1:

Thank you for your help with this. This seems to do what I've been trying to achieve. However, I do agree it's best to not modify the core functions.

Can you tell me what you mean by "But instead of using percentages to discount your items, adjust the sale values to .00"... I'm just not getting that. How exactly would I adjust the sales value to .00? Sorry if that's a dumb question?

I believe he means what he said in his example: When you're setting a product to be on sale, give it a fixed price instead of a percentage. So, instead of putting on sale for 15% off, set the actual product price to 33.00 if you want it to be 33.00 instead of 39.00. The calculated displayed percentage will still be 15%

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.