Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Addons for orders.php


jeanmi89

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

Link to comment
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

Link to comment
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

Link to comment
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.

Link to comment
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.

Link to comment
Share on other sites

Ok, I was wondering why that addslashes() function was there, and now we know. I'm glad it worked for you. Cheers!

 

 

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...