Jump to content
YePix

New function in general.php

Recommended Posts

Hi guys, maybe someone could take a look at this?

I do not get a value for this function. with php 7 it works but with php 8 nothing comes up.
Is there something I still have to pay attention to? Thank you in advance for your help.

function tep_get_products_stl_stock($products_id) {
$products_id = tep_get_prid($products_id);
$stock_query = tep_db_query("select products_stl_id from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
$stock_values = tep_db_fetch_array($stock_query);
$pstlid = $stock_values['products_stl_id'];
$slabel_product_query = tep_db_query("select stocklabel_stock from " . TABLE_PRODUCTS . " p, " . TABLE_STOCKLABEL . " sl where p.products_stl_id = '" . (int)$pstlid . "' and p.products_stl_id = sl.stocklabel_id");
$slabel_product = tep_db_fetch_array($slabel_product_query);
$stl_stock = $slabel_product['stocklabel_stock'];
return $stl_stock;
}

 

Share this post


Link to post
Share on other sites

ok, this is how it work.

// BOF stl stock check *******
function tep_get_products_stl_stock($products_id) {
$products_id = tep_get_prid($products_id);
$slabel_product_query = tep_db_query("select sl.stocklabel_stock from " . TABLE_PRODUCTS . " p, " . TABLE_STOCKLABEL . " sl where p.products_stl_id = sl.stocklabel_id");
$slabel_product = tep_db_fetch_array($slabel_product_query);
$stl_stock = $slabel_product['stocklabel_stock'];
return $stl_stock;
}

 

Share this post


Link to post
Share on other sites

 

// BOF stl stock check *******
function tep_get_products_stl_stock($products_id) {
$products_id = tep_get_prid($products_id);
$slabel_product_query = tep_db_query("select sl.stocklabel_stock from " . TABLE_PRODUCTS . " p, " . TABLE_STOCKLABEL . " sl where p.products_stl_id = sl.stocklabel_id");
$slabel_product = tep_db_fetch_array($slabel_product_query);
$stl_stock = $slabel_product['stocklabel_stock'];
return $stl_stock;
}

function tep_count_products_stl_stock_per_stl_id($products_id) {
global $customer_id;
$products_id = tep_get_prid($products_id);
$stock_query = tep_db_query("select products_stl_id from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
$stock_values = tep_db_fetch_array($stock_query);
$products_query = tep_db_query("select * from " . TABLE_CUSTOMERS_BASKET . " cb, " . TABLE_PRODUCTS . " p, " . TABLE_STOCKLABEL . " sl where cb.products_id = p.products_id and p.products_stl_id = '" . (int)$stock_values['products_stl_id'] . "' and p.products_stl_id = sl.stocklabel_id and cb.customers_id = '" . (int)$customer_id . "' and sl.stocklabel_status = '1'");
while($products = tep_db_fetch_array($products_query)) {
$qty += $products['customers_basket_quantity'];
}
return $qty;
}

function tep_check_stl_stock($products_id) {
$stock_stl_left = tep_get_products_stl_stock($products_id) - tep_count_products_stl_stock_per_stl_id($products_id);
$out_of_stl_stock = '';
if ($stock_stl_left < 0) {
$out_of_stl_stock = '<span class="text-danger"><b>' . STOCK_MARK_PRODUCT_OUT_OF_STL_STOCK . '&nbsp;' . OUT_OF_STL_STOCK_INFO_CHECKOUT . '</b></span>';
}
return $out_of_stl_stock;
}
// EOF stl stock check *******
//#################################################################

 

 

at checkout_payment.php this code just doesn't lead me back to the shopping cart. does anyone have an idea here?

// BOF stl stock check
if ( (STOCK_CHECK == 'true') && (STOCK_ALLOW_CHECKOUT != 'true') ) {
$products = $cart->get_products();
for ($i=0, $n=sizeof($products); $i<$n; $i++) {

$pID = current(explode("{", $products[$i]['id'])); 
$stl_stlstatus = current(explode("{", $products[$i]['stl_stlstatus'])); 

if ($stl_stlstatus == 1){
if (tep_count_products_stl_stock_per_stl_id($pID, $cart->get_products()) > tep_get_products_stl_stock($pID, $cart->get_products())){
tep_redirect(tep_href_link('shopping_cart.php'));
    }
  }
 }
}
// EOF stl stock check

 

Share this post


Link to post
Share on other sites

You should be checking the results of the querys. The code assumes the variable is set but it may not be. Also "sl.stocklabel_id" doesn't exist.

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

×