Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Showing Weight in Product Info


CC

Recommended Posts

Hi guys.

 

It is 3:00am here in the rainy UK, and I am losing my mind!

 

Could someone tell me what code I need to add in order to show the products weight on each product_info page please?

 

I have been trying for a while now, and it is just not happening! :?

Not to mention I am well knackered, and the body and mind went to sleep ages ago. :lookround:

 

So if you know the little bit of code I need just to show the weight of a product on the page, could you please drop it here?

 

Or PM or email me if you like.

 

cc@casetech.co.uk

 

Thanks guys.

 

CC.

Link to comment
Share on other sites

I think CC was looking to add the weight in the product info page, not the product listing.

 

I did the following quick hack on the product_info.php file:

 

Find the line:

 

$product_info = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . $HTTP_GET_VARS['products_id'] . "' and pd.products_id = '" . $HTTP_GET_VARS['products_id'] . "' and pd.language_id = '" . $languages_id . "'");

 

And add p.products_weight to the front of the query as follows:

 

$product_info = tep_db_query("select p.products_weight, p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . $HTTP_GET_VARS['products_id'] . "' and pd.products_id = '" . $HTTP_GET_VARS['products_id'] . "' and pd.language_id = '" . $languages_id . "'");

 

Then find the line:

</table><p><?php echo stripslashes($product_info_values['products_description']); ?></p>

 

And add the following line after it:

<p><b>(Weight: <?php echo $product_info_values['products_weight']; ?> lbs.)</b></p>

 

I would imagine that this should work for all languages, and of course you'll have to change the "lbs" to whatever unit of weight you want. I only did a quick test....if anyone has a better way of doing it, by all means feel free.

 

Good luck!

 

-Jim

Link to comment
Share on other sites

Oops...my mistake. The weight from the databaes next to the word "weight" *will* show up in in the product info no matter what language you choose, but it won't translate into the appropriate word or unit of measure.

 

Sorry for any confusion, but hopefully this will get you started in the right direction.

 

-Jim

Link to comment
Share on other sites

Thanks here for the post jficarra - i've been searching around all day for this and other things - which you used to be able to find easily until the developers decided to install this crappy BB - try an open search for "product listing" and be amazed at how a zero result is returned - there is a mountain of useful info in the old forums, but finding anything there is just about impossible - the search engine sux

 

I pointed out to the developers wayyyy back that they have this whole product listing thing about face - you can go into admin and set the product listing page to show everything, but the product info page shows zilch other than the product description, model and price.... here is where full product details need to be shown - to enter it all into product description is a (poor) solution....

 

what the app needs is for a way to add product attributes in admin, and for those to be shown in the product info page - I think the best way would be for a product *category* to be able to be assigned attributes particular to that category, so if you were say selling stamps, they do not need a weight attribute, but perhaps a rarity attribute would be handy, and if you also sell books then a publisher and author would be useful in that category etc. etc. etc.....

 

the only attribute handling oscommerce currently has is either turning what's available on or off globally in admin, or assigning 'options' - called attributes, to individual products (slow) - which in many cases in entirely unsuitable.

 

.... just looking at this.... why does the product options dialog not appear on the page when adding a new product??.... nope, you gotta add your product and then go elsewhere to add its options....hmmmm..... yes, it will appear in a live catalog before you have set the option, so do make sure its unavailable before you go to set your options.... oh yes... then you gotta come back again to activate your product..... what?... its gonna take you a month of sundays to do all this and fill your catalog?...... you better believe it!

 

 

I hope these things will be considered at least for version 3

Link to comment
Share on other sites

Nice one Jim

 

Now it is the next day my brain is working again.

It's amazing what sleep can do. :lol:

 

Yeh I have sorted it now.

Although my layout of product info is completely different, so I have had to alter the code you gave a tad.

Thanks for the pointer.

 

Mattifinn - I understand your points, but OSC will never be all things to all people.

That is why it is a basis for developers to start from.

If you feel things arnt as they should be, just change them, and maybe even start your own version for those that want it. i.e. just like Ian has done with his "Loaded" version.

 

Anyhow, back to the grindstone.

 

CC.

Link to comment
Share on other sites

Or ... you get the handy dandy Attribute Sorter Add-On and now you have both on the products page so you don't have to jump around.

 

v4.0 is on my site as I have a bug in there I am just fixing ... rumor is will be out today or tomorrow, based on David's fix of his Attribute Enhancer.

 

Mine is a modification of his that makes pretty tables and adds individual sort orders of the attributes for each product.

 

But, either one will get you to the products page and limit the need to go to the products attributes page.

Link to comment
Share on other sites

I decided to have some fun and try to learn a little more about the inner workings of OSCommerce, so I created a contribution that displays the product weight as discussed.

 

The contribuation, however, provides a parameter in the Admin tool to turn it off and on, as well as support for English, German and Spanish translations of weight and units.

 

This is my first contribution....be gentle. :wink:

I *think* I have the appropriate translations...if they're not correct, please let me know.

 

-Jim

Link to comment
Share on other sites

Doh! I had to upload version 1.1....I left out the database name in the installation instructions.

 

I don't suppose there's anyway to replace the previously uploaded file w/out creating a new version, eh?

 

Sorry about any confusion.

 

-Jim

Link to comment
Share on other sites

Nice one Jim

 

.

 

Mattifinn - I understand your points, but OSC will never be all things to all people.

 

CC.

 

I agree that it cannot be all things to all people - I do not expect that.

 

Its primary purpose is however to display products for sale in a catalog, yet there has been very little work in this regard for a long time - *how* the products are displayed... and as I have noted elsewhere, mods that were once available can no longer be found.

Link to comment
Share on other sites

In includes/functions/general.php

function tep_get_products_weight($product_id) {

   $weight_query = tep_db_query("select products_weight from " . TABLE_PRODUCTS . " where products_id = '" . $product_id . "'");

   $weight = tep_db_fetch_array($weight_query);



   return $weight['products_weight'];

 }

 

Somewhere in product_info.php:

 

<?php echo tep_get_products_weight($products_id); ?>

 

Pretty it up as you see fit.

Link to comment
Share on other sites

Burt, that is exactly what I was looking for, and that is what I did in the end.

 

Made it much easier to use on all pages, rather than just the product_info page.

 

CC.

Link to comment
Share on other sites

James,

 

The first part of the code is a functions and goes in includes/functions/general.php

 

The second part is the out put and you can put it where ever you want to in the page.

Link to comment
Share on other sites

:(

 

CC - that was manual work (i.e. little picture with weight) Hence why we want to make it non manual and use the icons and then "magically" input info from the site

 

We may be good at design - but PHP and MYSQL are still learning for us :(

 

:)

*I can see why you laughed*

:shock:

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...