Jump to content
jeanmi89

Addons for orders.php

Recommended Posts

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

Share this post


Link to post
Share on other sites

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']);

 

 


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

Share this post


Link to post
Share on other sites

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'])

 

 


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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

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

×