Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Recommended Posts

Posted

Hello everyone!

I want to know what's the total price of the stock that i have in my shop.

For example, if i only have 4 items avaliable in my shop and in stock, worth $1, $2, $3 and $4 the total price of the stock would be 1+2+3+4=$10 :)

 

Is there any contribuition there for this? Is there anybody able to make one?

Thanks a million!!!

:lol:

Posted

well here is some code for it

 

  $total = 0;
 $total_query = tep_db_query("select (products_price*products_quantity) as total from " . TABLE_PRODUCTS . "");
 while($total_array = tep_db_fetch_array($total_query) ) {
$total += $total_array['total'];
 }
 echo $currencies->display_price($total, 0);

 

you could add it in a script or something and display it. Haven't tested it or anything but you could alter the query to display the total per category or something.

Posted (edited)
well here is some code for it

 

  $total = 0;
 $total_query = tep_db_query("select (products_price*products_quantity) as total from " . TABLE_PRODUCTS . "");
 while($total_array = tep_db_fetch_array($total_query) ) {
$total += $total_array['total'];
 }
 echo $currencies->display_price($total, 0);

 

you could add it in a script or something and display it. Haven't tested it or anything but you could alter the query to display the total per category or something.

 

BRILLIANT!! Got it working, it's so simple! :thumbsup:

Ok, just in case someone is interested in this code, i copied in categories.php. Look for this code:

 

<td class="smallText"><?php echo TEXT_CATEGORIES . ' ' . $categories_count . '<br>' . TEXT_PRODUCTS . ' ' . $products_count; ?>

 

 

I added this:

 

<br>Total Stock for sale: <?php $total = 0;

$total_query = tep_db_query("select (products_price*products_quantity) as total from " . TABLE_PRODUCTS . "");

while($total_array = tep_db_fetch_array($total_query) ) {

$total += $total_array['total'];

}

echo $currencies->display_price($total, 0);

?>

 

 

Thank you so much enigma!!!

Edited by Melinda Odom
advertising is not allowed in your posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

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...