Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Product weight in grams with no decimal places.

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 05-21-2004, 02:45 AM
 
bluesunomi bluesunomi is offline
 

Member
  
Join Date: Feb 2004
Location: Oxford, UK
Posts: 22
 

Default Product weight in grams with no decimal places.

Hi,

If you have your site product weight set to just grams then it makes sense to remove the 2 decimal places when displaying product details as this is kind of meaningless (and at a glance misread). (i.e. 25 g looks better than 25.00 g)

I'm sure its not the only way of fixing this, but I've managed to sort this one by using the smarty math function to multiply the weight by 1 and format the output to 0 decimal places with

Code:
{math equation="x*1" x=$product.weight format="%.0f"}

This update affects Skin1\customer\main\product.tpl
(make sure you edit product, and not products with an s in the same directory or you'll get confused)

--------------

Update the following line - approx 26 lines from the top (which displays the product detail weight)

Code:
{if $product.weight ne "0.00"}<tr><td width=30%>{$lng.lbl_weight}</td><td nowrap>{$product.weight} {$config.General.weight_symbol}</td></tr>{/if}

with this one (replacing the {$product.weight} with the math function above)

Code:
{if $product.weight ne "0.00"}<tr><td width=30%>{$lng.lbl_weight}</td><td nowrap>{math equation="x*1" x=$product.weight format="%.0f"} {$config.General.weight_symbol}</td></tr>{/if}

And that's it !

Id be interested to know if there are any alternative or less compute intensive way of doing this - it's a shame smarty doesn't have a string function) - I think maybe a weight format option wouldn't be a bad idea for future relase maybe?

Anyway, TTFN,

John
Reply With Quote
  #2  
Old 05-21-2004, 06:50 AM
  shan's Avatar 
shan shan is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Birmingham, UK
Posts: 6,163
 

Default

try

{$product.weight|replace:".00":""}
__________________
Looking for a reliable X-cart host ?
You wont go wrong with either of these.

EWD Hosting
Hands On Hosting
Reply With Quote
  #3  
Old 05-21-2004, 07:46 AM
 
bluesunomi bluesunomi is offline
 

Member
  
Join Date: Feb 2004
Location: Oxford, UK
Posts: 22
 

Default

Usefull to know!

Thanks Shan.
Reply With Quote
  #4  
Old 05-21-2004, 07:48 AM
  shan's Avatar 
shan shan is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Birmingham, UK
Posts: 6,163
 

Default

http://smarty.php.net is mucho usefull
__________________
Looking for a reliable X-cart host ?
You wont go wrong with either of these.

EWD Hosting
Hands On Hosting
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 04:35 PM.

   

 
X-Cart forums © 2001-2020