How to display total items of each order in orders list?

turha71

No avatar

2007-02-08 23:32

Hi,

When I enter the order pendings the are this fields: ID, First and Last Name, Date, Status.

I need to add another field to it with the total of itens of eatch order.

How to do that?

Thanks!

» Quick.Cart v1.x

treewood (OpenSolution)

Avatar: treewood

2007-02-09 07:59

turha71 - You need to know PHP good. edit core/orders-admin.php and find listOrders function and there in "for" You need order products count. You need to open db/orders_products.php file and count all items.

Database structure will help You:
http://opensolution.org/download/?sDir=Quick.Cart/other

turha71

No avatar

2007-02-09 15:41

Hi treewood,

The new field I need is not with the count of the itens of all the orders, but the total itens of eatch order to be showed next to the other order fields in the order list.

Claps help with the basketsummary, making it to show all the itens in the basker, including the various itens of the same product. So I have the global $iBasketItems that have the total of itens of that particular order. Thats the value I want to show in the order list

Now I need to save that value do file and then read it to show in the new filed in the order list.

Where to go and how to do that?

Thanks

treewood (OpenSolution)

Avatar: treewood

2007-02-09 15:59

turha71 - maybe i dont understand. I give You advice "how to display items count for each order". do You want to display that? maybe i am wrong. if i am wrong maybe some image to give me more details?

turha71

No avatar

2007-02-09 17:03

Hi,

Yes thats What I want...

I'm not a programmer but i'm trying to follow the logic of it.

I add another filed called $aList['iCount'] in to the code:

for( $i = 0; $i < $iCount; $i++ ){
list( $aList['iOrder'], $aList['iTime'], $aList['iCourier'], $aList['sCourier'], $aList['fCourierPrice'], $aList['sFirstName'], $aList['sLastName'], $aList['sCompanyName'], $aList['sStreet'], $aList['sZipCode'], $aList['sCity'], $aList['sTelephone'], $aList['sEmail'], $aList['sIp'], $aList['sComment'], $aList['iCount'] ) = $aData[$i];

Now I need to give to that field the number of the itens of eatch order like, is that right?

$aList['iCount']= ????;

What to place there? I tryed $iCount but it's not working.

Thanks

P.S - Sorry if this is absoluty wrong:-)

treewood (OpenSolution)

Avatar: treewood

2007-02-09 22:17

turha71 - yes in this place. You must open file db/orders_products.php, count all items in each order etc. if You are not programmer then it will be hard. maybe someone will do it for You? Claps, Idaryl ? contact with them

turha71

No avatar

2007-02-10 16:22

Hi treewood,

I open the file orderstatistics.php and tryed to undertand the code from there because it extracts information from file orders_products.php and I came out with this code that I placed in the ordes_admin.php

$aFile = file( DB_ORDERS_PRODUCTS );
$nTotal = 0;
extract( $_GET );
$aFile[$i] = rtrim( $aFile[$i] );
$aExp = explode( '$', $aFile[$i] );
$nTotal += $aExp[3] ;
$aList['iCount']= $nTotal;

but it seams something is wrong because the new orders have the total with zero itens, and the total itens from order 2 appears in order 3 and the order 3 in order 2...

what's wrong?

Thanks

turha71

No avatar

2007-02-10 17:17

Well... I realise that I will need a loop to make it cross all the order_products.php file and make the calculations. How can I grab from file order_products.php the total of records of it to add it to a variable and use it for the loop?

turha71

No avatar

2007-02-11 01:24

Ok treewood...

My head is about to meltdown, but I think I solved the problem:-)

I let it for reference if others need to do the same:

STEP1 - edit core/order_admin.php

Add a new field to the end of $aList
i.e $alist['iCount']

It should look like this:

list( $aList['iOrder'], $aList['iTime'], $aList['iCourier'], $aList['sCourier'], $aList['fCourierPrice'], $aList['sFirstName'], $aList['sLastName'], $aList['sCompanyName'], $aList['sStreet'], $aList['sZipCode'], $aList['sCity'], $aList['sTelephone'], $aList['sEmail'], $aList['sIp'], $aList['sComment'], $aList['iCount'] ) = $aData[$i];

then after the line of code:

$aList['sStatus']= throwOrderStatus( $aStatus[$aList['iOrder']] );

add this:

$aFile = file( DB_ORDERS_PRODUCTS );
$Records = count( $aFile );
$nTotal = 0;
extract( $_GET );

for( $y = ($Records-1); $y > 0; $y-- ){
$aFile[$y] = rtrim( $aFile[$y] );
$aExp = explode( '$', $aFile[$y] );

if( ($iCount-$i) == $aExp[1] )
$nTotal += $aExp[3] ;
}

$aList['iCount']= $nTotal;


STEP 2 - edit templates/admin/orders_list.php

in the List_Head after the field of the date add this:

<td>
Total Itens
</td>

in the List_List after the field of the date add this:

<td>
$aList[iCount]
</td>

And that's it!

Best Regards

idaryl

Avatar: idaryl

2007-02-11 10:20

So lets see here - you add this to what you covered before...or is this a differnt set of functions?... and not use the others?

turha71

No avatar

2007-02-12 01:18

Hi idaryl,

Don't use the others, just the code of the last post.

Regards

idaryl

Avatar: idaryl

2007-02-12 04:40

Ok thanks a lot - I'll try it

turha71

No avatar

2007-02-13 16:16

Well, it seams there is still something missing... the code is not working well.

When we see the list of all the orders, everything is ok, but when I select an option in the status, and show only the orders of that status the value of the itens appears in the fields of other itens.

What to do? Where to go? Any tips? please!!!

Thanks.

treewood (OpenSolution)

Avatar: treewood

2007-02-13 19:16

turha71 - strange ... listOrders function is only one function to list orders. could You send screen shot or something ?

http://www.freeimagehosting.net/

turha71

No avatar

2007-02-13 20:27

Hi treewood,

here it goes the screenshots:

The fist one you can see all the orders. Everything it's ok. All the itens have the values in place. http://www.horiah.org/status_all.jpg

The ID 5 and 4 have the status "finalizado". When I select the status option "finalizado" to show only this orders, the value of the itens change to the wrong ones.

http://www.horiah.org/status_finalizado.jpg

Thanks

turha71

No avatar

2007-02-13 20:35

And when I select the status "pendente" it show the same values, that are the ones that appears in the bottom of the list in the status_all
http://www.horiah.org/status_pendente.jpg

so, it's like the code is reading the two last values of the array an place it, insted of showing the values of eatch entry...

thanks.

treewood (OpenSolution)

Avatar: treewood

2007-02-13 22:56

turha71 - maybe it will help. replace code You written to this:

<?php 
$aFile 
fileDB_ORDERS_PRODUCTS );
$iCount2 count$aFile );
$aList['iCount'] = 0;
for( 
$i2 1$i2 $iCount2$i2++ ){
  
$aExp explode'$'$aFile[$i2] );
  if( 
$aList['iOrder'] == $aExp[1] ){
    
$aList['iCount'] += $aExp[3];
  }
}
?>

turha71

No avatar

2007-02-14 00:17

Thanks treewood,

It's working fine now.

turha71

No avatar

2007-02-14 00:29

If someone want's to use this code just ignore all previews posts written by me and use this one as reference:

STEP1 - edit core/order_admin.php

Add a new field to the end of $aList
i.e $alist['iCount']

It should look like this:

list( $aList['iOrder'], $aList['iTime'], $aList['iCourier'], $aList['sCourier'], $aList['fCourierPrice'], $aList['sFirstName'], $aList['sLastName'], $aList['sCompanyName'], $aList['sStreet'], $aList['sZipCode'], $aList['sCity'], $aList['sTelephone'], $aList['sEmail'], $aList['sIp'], $aList['sComment'], $aList['iCount'] ) = $aData[$i];

then after the line of code:

$aList['sStatus']= throwOrderStatus( $aStatus[$aList['iOrder']] );

add this:

$aFile = file( DB_ORDERS_PRODUCTS );
$iCount2 = count( $aFile );
$aList['iCount'] = 0;
for( $i2 = 1; $i2 < $iCount2; $i2++ ){
$aExp = explode( '$', $aFile[$i2] );
if( $aList['iOrder'] == $aExp[1] ){
$aList['iCount'] += $aExp[3];
}
}


STEP 2 - edit templates/admin/orders_list.php

in the List_Head after the field of the date add this:

<td>
Total Itens
</td>

in the List_List after the field of the date add this:

<td>
$aList[iCount]
</td>

And that's it!

Best Regards to all and thanks again treewood

idaryl

Avatar: idaryl

2007-02-14 03:49

thuha71 -- thank you for proving the finished result it will help in a project I have ongoing - thank you

Back to top
about us | contact