Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

instock product count


Guest

Recommended Posts

can anyone figure out why this query isn't working?

 

$order_count_query = tep_db_query("select p.products_quantity, pd.products_name, op.products_name from products_description as pd., products as p., orders_products as op. where pd.products_name = 'op.products_name'");
$order_count = tep_db_fetch_array($order_count_query);
echo $order_count['op.products_name'];

 

i'm trying to display on admin/orders.php how many products i have instock for the particular item that was purchased

Link to comment
Share on other sites

try this - not tested, but corrected several things ...

$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 p.products_id = op.products_id");
$order_count = tep_db_fetch_array($order_count_query);
echo $order_count['products_quantity'] . ' '. $order_count['products_name'];

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Link to comment
Share on other sites

that works, but it's bringing up the first product in the database.. how can i get it to pull up the current product's count instead?

 

could i just position the code in a different spot maybe?

right now i have it BENEATH:

' <td class="dataTableContent" valign="top" align="right">' . $order->products[$i]['qty'] . ' x</td>' . "\n" .
' <td class="dataTableContent" valign="top">' . $order->products[$i]['name'];

Link to comment
Share on other sites

got it to work for the product :)

but now it's only showing the FIRST product, any idea how to get it to show individually for each product purchased?

 

code:

$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 p.products_id = op.products_id and op.orders_id = '".$HTTP_GET_VARS['oID']."'");
$order_count = tep_db_fetch_array($order_count_query);
echo '"',$order_count['products_quantity'],'"' . ' '. $order_count['products_name'];

Link to comment
Share on other sites

got it :) thanks for your help, bruyndoncx!! i wouldn't have been able to figure this out if you hadn't cleaned my code :D

Link to comment
Share on other sites

You need to use the tep_get_products_inventory function:

 

ADD to admin/includes/functions/general.php

 

THIS CODE:

 

// BEGIN quantity in orders display MOD

function tep_get_products_inventory_qty($product_id) {

$product_query = tep_db_query("select products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . (int)$product_id . "'");

$product = tep_db_fetch_array($product_query);

 

return $product['products_quantity'];

}

// END quantity in orders display MOD

 

 

 

ADD to orders.php: (you will have to compare. This is only an example)

See the area marked // MOD START quantity in orders

 

 

THIS CODE:

 

<?php

for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {

 

// I added the qty_shipped query below to show the number of products shipped

//$quantity_shipped_query = tep_db_query("select qty_shp, orders_id from " . TABLE_SPG_PRODUCTS_SHIPPING . " where orders_id = '" . $order->products[$i]['id'] . "' order by orders_id");

//$qty_shipped = tep_db_fetch_array($quantity_shipped_query);

 

$returns_check_query = tep_db_query("select r.rma_value, rp.products_id from " . TABLE_RETURNS . " r, " . TABLE_RETURNS_PRODUCTS_DATA . " rp where r.returns_id = rp.returns_id and r.order_id = '" . (int)$oID . "' and rp.products_id = '" . $order->products[$i]['id'] . "' ");

 

if (!tep_db_num_rows($returns_check_query)) {

$return = ' ';

} else {

$returns = tep_db_fetch_array($returns_check_query);

$return_link = '<a href=' . tep_href_link(FILENAME_RETURNS, 'cID=' . $returns['rma_value']) . '><font color=red><b><i>Returns</b></i></font></a>';

}

 

echo ' <tr class="dataTableRow">' . "\n" .

// MOD START quantity in orders

' <td class="dataTableContent" align="left" valign="top">  ' . tep_get_products_inventory_qty($order->products[$i]['id_product']) . '</td>' . "\n" .

// MOD END quantity in orders

' <td class="dataTableContent" align="left" valign="top">     ' . $shipping->products[$i]['qtys'] . '</td>' . "\n" .

' <td class="dataTableContent" valign="top" align="right">' . $order->products[$i]['qty'] . ' x</td>' . "\n" .

' <td class="dataTableContent" valign="top"><a href="' . tep_href_link(FILENAME_CATEGORIES, 'action=new_product&read=only&pID=' . $order->products[$i]['id'] . '&oID=' . (int)$oID . '&origin=' . FILENAME_ORDERS . '?oID=' . (int)$oID . '&retOID=' . (int)$oID . '&retAction=edit') . '">' . $order->products[$i]['name'] . '</a>  '. $return_link;

 

if (isset($order->products[$i]['attributes']) && (sizeof($order->products[$i]['attributes']) > 0)) {

for ($j=0, $k=sizeof($order->products[$i]['attributes']); $j<$k; $j++) {

echo '<br><nobr><small><i>' . $order->products[$i]['attributes'][$j]['option'] . ': ' . $order->products[$i]['attributes'][$j]['value'];

if ($order->products[$i]['attributes'][$j]['price'] != '0') echo ' [ ' . $order->products[$i]['attributes'][$j]['prefix'] . $currencies->format($order->products[$i]['attributes'][$j]['price'] * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . ' ]';

echo '</i></small></nobr>';

}

}

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...