jeanmi89 Posted December 3, 2021 Share Posted December 3, 2021 Good evening, Oscommerce 2.2 I have a problem with this addon: "Display stock count in admin/orders.php "We add that to the file " orders.php" (to add the stock of the product on the order form, which makes it possible to check the stocks while preparing the orders. ) $order_count_query = tep_db_query("select p.products_quantity, pd.products_name from products_description pd, products p, orders_products op where p.products_id = pd.products_id and pd.products_name = '".addslashes($order->products[$i]['name'])."' and op.orders_id = '".$HTTP_GET_VARS['oID']."'"); $order_count = tep_db_fetch_array($order_count_query); echo ' ', $order_count['products_quantity'], ' in-stock'; It works very well unless 2 articles have the same name. I would therefore like the stock of the article to be taken in relation to the model (for me "model" is a unique code whereas several articles can have the same name.) I tried to fiddle with the code a little, but I Unfortunately, doesn't know much about sql , if someone could tell me how to transform the code, that would be cool. Thank you Quote Link to comment Share on other sites More sharing options...
Demitry Posted December 4, 2021 Share Posted December 4, 2021 Give this a try. This is based on the product model. Though I have not tested it, and the attributes FOR loop follows this code. Uncomment that print_r(); statement to see if this works based on the quantity of how many products you have of that model. $order_count_query = tep_db_query("select p.products_quantity, p.products_model, pd.products_name from products_description pd, products p, orders_products op where p.products_id = pd.products_id and pd.products_name = '" . addslashes($order->products[$i]['name']) . "' and p.products_model = ' . $order->products[$i]['products_model']) . ' and op.orders_id = '" . $_GET['oID'] . "'"); $order_count = tep_db_fetch_array($order_count_query); echo ' ' . $order_count['products_quantity'] . ' in-stock'; //print_r(' There are ' . $order_count['products_quantity'] . ' in-stock of model: ' . $order_count['products_model']); Quote osCommerce: made for programmers, ...because store owners do not want to be programmers. https://trends.google.com/trends/explore?date=all&geo=US&q=oscommerce Link to comment Share on other sites More sharing options...
Demitry Posted December 4, 2021 Share Posted December 4, 2021 I just realized that the query I posted may fail. Please replace the following in that SQL query: $order->products[$i]['products_model']) with this: $order->products[$i]['model']) Quote osCommerce: made for programmers, ...because store owners do not want to be programmers. https://trends.google.com/trends/explore?date=all&geo=US&q=oscommerce Link to comment Share on other sites More sharing options...
jeanmi89 Posted December 4, 2021 Author Share Posted December 4, 2021 Bonjour Demitry, Merci d'esayer de m'aider. J'ai une erreur: Quote 1 x ENCENS SATYA OPIUM BOITE1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'model']) . ' and op.orders_id = '21739'' at line 1 select p.products_quantity, p.products_model, pd.products_name from products_description pd, products p, orders_products op where p.products_id = pd.products_id and pd.products_name = 'ENCENS SATYA OPIUM BOITE' and p.products_model = ' . Array[0]['model']) . ' and op.orders_id = '21739'[TEP STOP] Je pense qu'il n'y a même pas besoin de se servir du nom, le model suffirait, mais je ne sait toujours pas comment m'y prendre. Quote Link to comment Share on other sites More sharing options...
jeanmi89 Posted December 4, 2021 Author Share Posted December 4, 2021 Bin finalement après plusieurs essais , ça a l'air de marcher comme ça: Quote $order_count_query = tep_db_query("select p.products_quantity, p.products_model, pd.products_name from products_description pd, products p, orders_products op where p.products_id = pd.products_id and p.products_model = '".addslashes($order->products[$i]['model'])."' and op.orders_id = '".$HTTP_GET_VARS['oID']."'"); $order_count = tep_db_fetch_array($order_count_query); echo ' ', $order_count['products_quantity'], ' en-stock'; Merci beaucoup pour ton aide Demitry. Passe une bonne journée. Demitry 1 Quote Link to comment Share on other sites More sharing options...
Demitry Posted December 4, 2021 Share Posted December 4, 2021 Ok, I was wondering why that addslashes() function was there, and now we know. I'm glad it worked for you. Cheers! Quote osCommerce: made for programmers, ...because store owners do not want to be programmers. https://trends.google.com/trends/explore?date=all&geo=US&q=oscommerce Link to comment Share on other sites More sharing options...
jeanmi89 Posted December 4, 2021 Author Share Posted December 4, 2021 I just noticed that I am posting in French, sorry for that. Just the habits. I'll try to be careful next time. Thanks again. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.