Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

HELP FETCHING STOCK QTY. FROM DATABASE!


Recommended Posts

Hi all,

 

I have installed the AVAILABILITY CONTRIBUTION which basically shows a message in product_info.php. The message, depending on whether the stock qty. is > 1 or < 1 shows either IN STOCK or OUT OF STOCK.. This is a great contrib that works perfect on my LOCALHOST, but when I go live with it, it just shows every single product as OUT OF STOCK even when the qty. is greater the 1..

 

This is so unusual. Its the EXACT same install on the LOCALHOST as it is live. I checked everything 100x over, so I'm quite sure!!!

 

So I'm thinking it has something to do with this code which displays the availablity message (IN STOCK for greater than 1qty and OUT OF STOCK 0qty) in product_info.php. SEE IT BELOW:

 

// BOF: Availability

$availability_query = tep_db_query("select * from availability where language_id = " . $languages_id . " order by availability_id");

$availability_array = array();

while ($availability_tmp = tep_db_fetch_array($availability_query)) {

$availability_array[$availability_tmp['availability_id']] = $availability_tmp['availability_name'];

//$availability_array[] = array( 'id' => $availability_tmp['availability_id'], 'text' => $availability_tmp['availability_name']);

}

$prod_quantity = tep_get_products_stock($products_id);

if ($prod_quantity < 1) {

echo "<p><b>".TABLE_HEADING_AVAILABILITY." ".sprintf($availability_array[$product_info['availability_id_out_of_stock']],$product_info['products_quantity'])."</p>";

} else {

echo "<p>".TABLE_HEADING_AVAILABILITY." ".sprintf($availability_array[$product_info['availability_id_in_stock']],$product_info['products_quantity'])."</p>";

}

// EOF: Availability ?>

 

 

I think the problem is with this line:

 

$prod_quantity = tep_get_products_stock($products_id);

 

Now I just dont know how to get it to get my actual stock values here. And I checked the database too. Everything is correct under product_quantity in the products TABLE.

 

So I NEED HELP!!!! Everything in store just shows OUT OF STOCK!! And this only happens for the livestore, not the one on the localhost..

 

Is there modifucation to this that somone to create that will fix this problem?? PLEASE SOMEONE, ANYONE HELP ME!!!! I spent hours last night tweaking this code but to no avail...

 

HELP ME!!!!

Link to comment
Share on other sites

Hi all,

 

I have installed the AVAILABILITY CONTRIBUTION which basically shows a message in product_info.php. The message, depending on whether the stock qty. is > 1 or < 1 shows either IN STOCK or OUT OF STOCK.. This is a great contrib that works perfect on my LOCALHOST, but when I go live with it, it just shows every single product as OUT OF STOCK even when the qty. is greater the 1..

 

This is so unusual. Its the EXACT same install on the LOCALHOST as it is live. I checked everything 100x over, so I'm quite sure!!!

 

So I'm thinking it has something to do with this code which displays the availablity message (IN STOCK for greater than 1qty and OUT OF STOCK 0qty) in product_info.php. SEE IT BELOW:

 

// BOF: Availability

$availability_query = tep_db_query("select * from availability where language_id = " . $languages_id . " order by availability_id");

$availability_array = array();

while ($availability_tmp = tep_db_fetch_array($availability_query)) {

$availability_array[$availability_tmp['availability_id']] = $availability_tmp['availability_name'];

//$availability_array[] = array( 'id' => $availability_tmp['availability_id'], 'text' => $availability_tmp['availability_name']);

}

$prod_quantity = tep_get_products_stock($products_id);

if ($prod_quantity < 1) {

echo "<p><b>".TABLE_HEADING_AVAILABILITY." ".sprintf($availability_array[$product_info['availability_id_out_of_stock']],$product_info['products_quantity'])."</p>";

} else {

echo "<p>".TABLE_HEADING_AVAILABILITY." ".sprintf($availability_array[$product_info['availability_id_in_stock']],$product_info['products_quantity'])."</p>";

}

// EOF: Availability ?>

 

 

I think the problem is with this line:

 

$prod_quantity = tep_get_products_stock($products_id);

 

Now I just dont know how to get it to get my actual stock values here. And I checked the database too. Everything is correct under product_quantity in the products TABLE.

 

So I NEED HELP!!!! Everything in store just shows OUT OF STOCK!! And this only happens for the livestore, not the one on the localhost..

 

Is there modifucation to this that somone to create that will fix this problem?? PLEASE SOMEONE, ANYONE HELP ME!!!! I spent hours last night tweaking this code but to no avail...

 

HELP ME!!!!

 

 

That seams very ott just to display stock, why is it needing a sql query, do you have umpteen stock value texts?? you could have just used:

 

$stock = tep_get_products_stock($products_id);
echo ($stock ? $stock . ' available' : 'OUT OF STOCK');

 

In anycase, the error you have is probable due to not setting $products_id

Sam

 

Remember, What you think I ment may not be what I thought I ment when I said it.

 

Contributions:

 

Auto Backup your Database, Easy way

 

Multi Images with Fancy Pop-ups, Easy way

 

Products in columns with multi buy etc etc

 

Disable any Category or Product, Easy way

 

Secure & Improve your account pages et al.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...