Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

weight in grammes


theherbman

Recommended Posts

I have managed to change from lb's to kg's but I need to have the product weight shown in gms. Is this possible e.g. its possible for 100 gms to be shown as 0.10 but is it possible to be shown as "100 gms" any ideas.

Link to comment
Share on other sites

Logic would be something like

 

if (products_weight <= 1.0){

echo (products_weight * 100) .' grams';

} else{

echo products_weight .' kgs';

}

Need help installing add ons/contributions, cleaning a hacked site or a bespoke development, check my profile

 

Virus Threat Scanner

My Contributions

Basic install answers.

Click here for Contributions / Add Ons.

UK your site.

Site Move.

Basic design info.

 

For links mentioned in old answers that are no longer here follow this link Useful Threads.

 

If this post was useful, click the Like This button over there ======>>>>>.

Link to comment
Share on other sites

  • 1 year later...

@ geoffreywalton

that logic seems to be fine but where shall we put it.

 

may be in template product page Kg(s) shall be replaced by this code by you?

pls guide us!

 

Thanks

/catalog/includes/modules/product_listing.php

 

case 'PRODUCT_LIST_WEIGHT':

$lc_align = 'right';

$lc_text = ' ' . $listing['products_weight'] . ' ';

break;

Would be replaced with:

 

case 'PRODUCT_LIST_WEIGHT':

$lc_align = 'right';

if ( (int)$listing['products_weight'] <= 1.0 ){

$lc_text = ' ' . (int)($listing['products_weight']*100) . 'grams ';

} else {

$lc_text = ' ' . $listing['products_weight'] . 'kgs ';

}

break;

I had to use a text box instead of a code box or the forum strips out the non-breaking space!

:'(

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...