Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Help with changing tep_check_stock function


Portman

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

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...