YePix Posted November 28, 2021 Share Posted November 28, 2021 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; } Link to comment Share on other sites More sharing options...
YePix Posted November 28, 2021 Author Share Posted November 28, 2021 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; } Link to comment Share on other sites More sharing options...
Hotclutch Posted November 28, 2021 Share Posted November 28, 2021 You need to turn error reporting on to see where the code fails. You can try replacing return $stl_stock with return $stl_stock ?? null; or return $stl_stock ?? ''; Link to comment Share on other sites More sharing options...
YePix Posted November 28, 2021 Author Share Posted November 28, 2021 // 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 . ' ' . 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 Link to comment Share on other sites More sharing options...
Jack_mcs Posted November 28, 2021 Share Posted November 28, 2021 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. Support Links: For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc. All of My Addons Get the latest versions of my addons Recommended SEO Addons Link to comment Share on other sites More sharing options...
YePix Posted November 28, 2021 Author Share Posted November 28, 2021 thank you all. the STOCK_ALLOW_CHECKOUT != 'true' was set incorrectly. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.