CC Posted October 29, 2002 Share Posted October 29, 2002 Hopefully this will have got Burts attention. But if not I am sure many of yo0u out there can help me see what I am doing wrong here... I have added this code to my site to give an indication of stock levels for each product. <?phpswitch ($prod_quantity) { case 0: print "Out of Stock"; break; case 1: print "We have 1 in stock"; break; case 2: print "We have 2 in stock"; break; case 3: print "We have 3 in stock"; break; case 4: print "We have 4 in stock"; break; default: print "We have 5+ in stock"; } ?> Now, this works as far as the Out of Stock feature. But when I have got stock of a product. i.e. I have 20 cable, it does not show 5+. It just stays on Out Of Stock. It is as tho the code cant see the database and recognise that more than '0' is in stock. Please help me if you can on this. Especially Burt, cos he got me rolling on this to begin with. Once it is complete I will badge it up as a Contribution and post it. Thanks in advance. CC. Quote Link to comment Share on other sites More sharing options...
Ajeh Posted October 29, 2002 Share Posted October 29, 2002 What is giving you the value for $prod_quantity? Quote Link to comment Share on other sites More sharing options...
CC Posted October 29, 2002 Author Share Posted October 29, 2002 How do you mean Linda? Could it be this: $prod_quantity = tep_get_products_stock($listing_array[$i]['products_id']); CC. Quote Link to comment Share on other sites More sharing options...
Ajeh Posted October 29, 2002 Share Posted October 29, 2002 What page are you on for that peice of code? It's valid if there is an array with that value in it for the products_id but if that is just stuck where ever ... then it is sending the wrong products_id to the function. Quote Link to comment Share on other sites More sharing options...
CC Posted October 29, 2002 Author Share Posted October 29, 2002 Oh ok, I follow you a bit better now. I think... :lol: This is currently posted into the products_info page. I am just integrating it here first, then looking elsewhere to put it. If you have a possible solution I am more than willing to give it a go. Could you explain more what I would have to do, depending on where I put the code, to make it work on other pages please...? Cheers CC. Quote Link to comment Share on other sites More sharing options...
CC Posted October 29, 2002 Author Share Posted October 29, 2002 Anyone please.... Did you give up on me Linda?? :lol: CC. Quote Link to comment Share on other sites More sharing options...
CC Posted October 29, 2002 Author Share Posted October 29, 2002 nice1 M8. works a treat. Cant believe that was all I had wrong. Sheeeesh... I should get my php book out more...! :lol: Thnx again Burt. CC. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.