Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

changing product id to varchar from int


rickerny

Recommended Posts

Posted

I changed in phpadmin the defaults for product id to varchar from int so that i could add letters to my product ids. Everything is connected fine, except on the webpage, the three products that have ids with letters are not generating any descriptions. Does anyone know if there is any specific code that must be modified as well besides the database tables in mysql?

I would really appreciate if anyone could help me on this.

 

Thanks,

Rick

Posted

With varchar you can use letters and numbers.

Posted

Thanks for the response, but that's something i already knew. The problem is that the products that have letters in their product id are not displaying their descriptions on the webpage. I was wondering if there might be some code in the indes.php that i need to modify. Anybody?

Posted

I have a really modified store so this could be wrong - but if you are reffering to product_info.php not giving you the discriptions i know that the $product_info_query has

p.products_id = '" . (int)$HTTP_GET_VARS['products_id']

in it so if your product id has a letter in it - it int a int :) (thus returning no row)

 

Hope this helps

 

Sam

Posted

okay, i tried changing that (int) to (varchar), but i got a parse error. Is there another variable that should be changed to in order to allow the letters in the product id? thanks for all the help!

Posted

it has to be a data type (e.g. int, float, etc etc - varchar isn't) or just try removing the int all together - will probebly do it

Posted
I changed in phpadmin the defaults for product id to varchar from int so that i could add letters to my product ids.

You shouldn't.

  • You'll have bugs all around, osCommerce depends on ids being integers, and
  • Ids are used internally as primary and foreign keys. Their actual value should not be used. If you need a code, just add a products_code field and use that.

Christian Lescuyer

Posted

interesting. i thought there might be some kind of a snag like that. If i add another field though, will i have to reconfigure the preexisting fields. The reason i want to allow varchar for the prod id is so that i can recognize the prod id # easily without having to necessarily look it up in the product description table. So, if i bring everything back to the int values, and then add this extra field, i'm not sure it will really help with what i'm looking to do. There will be a field with the id i want, but in order to make use of it, i will still have to keep going back to compare the int prod id with the new field. Is there another possible way to do this?

Again, thanks for all the help!!!

Posted

I understand you'd like to recognize the product from the URL?

 

Of course you can modify the code to use alphanum products_ids. It's not *that* difficult, but you'll have to check everywhere a products_id is used, and possibly change the code. There is a trick you can see if you select a product with attributes.

 

Maybe you could add &products_model=<CODE> to the URL you're interested in?

Christian Lescuyer

Posted

I added an 'Item Number' field using the instructions found in this contribution:

 

http://www.oscommerce.com/community/contri...earch,new+field

 

I've carried the number through from the product_info.php page to the checkout pages and into the Email confirmation and order form. You can see it in action via the WWW link below.

 

HTH,

 

Terry

Terry Kluytmans

 

Contribs Installed: Purchase Without Account (PWA); Big Images, Product Availability, Description in Product Listing, Graphical Infobox, Header Tags Controller, Login Box, Option Type Feature, plus many layout changes & other mods of my own, like:

 

Add order total to checkout_shipment

Add order total to checkout_payment

Add radio buttons at checkout_shipping (for backorder options, etc.)

Duplicate Table Rate Shipping Module

Better Product Review Flow

 

* If at first you don't succeed, find out if there's a prize for the loser. *

Archived

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

×
×
  • Create New...