Jump to content

Calculate total stock value


Guest chris121

Recommended Posts

Guest chris121

Hi, looking to try and calculate the total value of current in stock products, using cubecart 4

any info or help out there, seen some ideas for cube 3 versions but none for cube 4

any help out there for these

thank you

Ken

Link to comment
Share on other sites

Hi

Try this, it will give you the total value of all in-stock products.

Open admin/sources/home/index.inc.php and find this code (around line 23)

require($glob['adminFolder'].CC_DS.'includes'.CC_DS.'header.inc.php');


Add underneath...


require($glob['adminFolder'].CC_DS.'includes'.CC_DS.'currencyVars.inc.php');


Just below you will see this...


// no Products

$query = 'SELECT count(`productId`) as noProducts FROM '.$glob['dbprefix'].'CubeCart_inventory';

$noProducts = $db->select($query);


Add this below...


// total product value

$query = 'SELECT sum(`stock_level`*`price`) as totValue FROM '.$glob['dbprefix'].'CubeCart_inventory WHERE `stock_level` > 0';

$totValue = $db->select($query);


Around line 243 find this...


  <tr>

    <td width="33%" class="tdText"><span class="tdText"><?php echo $lang['admin_common']['other_no_products'];?></span></td>

    <td width="50%" class="tdText"><?php echo number_format($noProducts[0]['noProducts']); ?></td>

  </tr>


Add this under it...


    <tr>

    <td width="33%" class="tdText"><span class="tdText">Total value of in-stock products:</span></td>

    <td width="50%" class="tdText"><?php echo priceFormat($totValue[0]['totValue'],true); ?></td>

  </tr>

This could be refined a little more if need be....

Lee

Link to comment
Share on other sites

Guest chris121

Hi Lee, ok we have the below done, tried to follow the format of the file and added in your lines

, copied our file with the bits added to see if you think is written in correct.

tried to look under View productions and do the search there but nothing new comes up in the search option boxes still

1st and 2nd one added

$lang = getLang("admin".CC_DS."admin_misc.inc.php");

require($glob['adminFolder'].CC_DS."includes".CC_DS."header.inc.php");

require($glob['adminFolder'].CC_DS.'includes'.CC_DS.'currencyVars.inc.php');

// no Products

$query = "SELECT count(productId) as noProducts FROM ".$glob['dbprefix']."CubeCart_inventory";

$noProducts = $db->select($query);

// total product value

$query = 'SELECT sum(`stock_level`*`price`) as totValue FROM '.$glob['dbprefix'].'CubeCart_inventory WHERE `stock_level` > 0';

$totValue = $db->select($query);

// no Categories

$query = sprintf("SELECT COUNT(S.cart_order_id) as noOrders FROM %1\$sCubeCart_order_sum AS S, %1\$sCubeCart_customer AS C WHERE C.customer_id = S.customer_id", $glob['dbprefix']);

$noOrders = $db->select($query);

3rd one added below

// no Products

$query = "SELECT count(productId) as noProducts FROM ".$glob['dbprefix']."CubeCart_inventory";

$noProducts = $db->select($query);

// total product value

$query = 'SELECT sum(`stock_level`*`price`) as totValue FROM '.$glob['dbprefix'].'CubeCart_inventory WHERE `stock_level` > 0';

$totValue = $db->select($query);

// no Categories

$query = sprintf("SELECT COUNT(S.cart_order_id) as noOrders FROM %1\$sCubeCart_order_sum AS S, %1\$sCubeCart_customer AS C WHERE C.customer_id = S.customer_id", $glob['dbprefix']);

$noOrders = $db->select($query);

Link to comment
Share on other sites

Guest chris121

Hi yep it is, many thanks, that helps alot

just quick thing, we currently use the kitablue format for the site, if we change t the other default ones, the images etc are not correct and overlay the colums etc, is like the colums and layout gets shrunk to standard size and doesn't adjust

is there any codes to make the other skins on the site to work the same as the kitablue, think others have asked this before

Link to comment
Share on other sites

  • 1 month later...

I won't explain how, as others have said it needs to be done with caution, but I export the "Inventory" table through PHP-MyAdmin and read it into Excel, then you can do what you want with the data... Category Summaries, Pivot Tables, Conditional Formatting, Management Reports, etc, etc...

Obviously needs to be done carefully, but if you're happy hacking program code around, you're probably competent enough to suck some data out of the database...

Dave

Bits4Vits

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