Jump to content
Latest News: (loading..)
Portman

Help with changing tep_check_stock function

Recommended Posts

Hi,

I am trying to make it so that I can check stock quantities on certain items only (some stock we always have available because we produce them on demand, other items we order in and on-sell to our customers)

I have added a field in the products table "products_count_stock" which defaults to "0" and can be changed to "1" in admin/categories.php - this bit I got to work fine

Now what I am trying to do is that every time a page calls the function tep_check_stock I want it not only to pass the products_id and products_quantity fields but also the products_count_stock field so that I can check within tep_check_stock if products_count_stock is true (1)

so far I have been playing around with shopping_cart.php, all I have done is change the following code;

     if (STOCK_CHECK == 'true') {
        $stock_check = tep_check_stock($products[$i]['id'], $products[$i]['count_stock'], $products[$i]['quantity']);// - added 'count_stock'
        if (tep_not_null($stock_check)) {
          $any_out_of_stock = 1;

          $products_name .= $stock_check;
        }
      }

obviously this does not work as  to test it I have put an echo in the tep_check_function to show the value of the three variables and the count_stock variable always comes up empty.

  function tep_check_stock($products_id, $products_count_stock, $products_quantity) {
	   echo "value:" . $products_id . "," . $products_count_stock . "," . $products_quantity ;  //- My Mod
	 if ($products_count_stock == "1"); // -- My Mod
    $stock_left = tep_get_products_stock($products_id) - $products_quantity;
    $out_of_stock = '';

    if ($stock_left < 0) {
      $out_of_stock = '<span class="markProductOutOfStock">' . STOCK_MARK_PRODUCT_OUT_OF_STOCK . '</span>';
    }

    return $out_of_stock;
  } // - My Mod
  }

I am not a great coder but if someone could point me in the right direction, I'd' really appreciate it

Share this post


Link to post
Share on other sites

Can get it simpler.

Use for products_quantity

-1

0

1

then

if ($stock_left== 0)

and in checkout_process.php check

if ($stock_left>= 0 ) {

Edited by ruden

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×