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

Hide Add To Cart, Buy and Buy Now for out of stock items

Recommended Posts

@puggybelle

Close....
You cannot use $product_info[products_quantity] in the new_products modules. Two reasons why.

1. look at the code, all variables are like $new_products['products_id'] or $new_products['products_image'] use $new_products and not $product_info because well it is a new_products module.

2. the p.products_quantity check is not inside the new products database query so it cannot understand and check for it. Therefore we use the same function as we used in the product_listing file, tep_get_products_stock, which checks for the products_quantity. That combined with the right variable $new_products['products_id'] becomes

if ( tep_get_products_stock($new_products['products_id']) >= 1) {

If you want to know what the tep_get_products_stock does. Here the function code (inside general.php)

////
// Return a product's stock
// TABLES: products
  function tep_get_products_stock($products_id) {
    $products_id = tep_get_prid($products_id);
    $stock_query = tep_db_query("select products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
    $stock_values = tep_db_fetch_array($stock_query);

    return $stock_values['products_quantity'];
  }

 

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

×