New value in orders list

cachousam

Avatar: cachousam

2014-02-14 16:23

Hello,
I would like to see the amount of each order in the list of orders in the Admin panel.
I managed to create space in the title of the list by editing the template file / admin / order.php and inserting the following line:

<td class="summary"><?php echo $lang['Summary']; ?> [<?php echo $config['currency_symbol']; ?>]</td>

But in the file core /orders-admin.php , I do not know what value to write.

Surely a value of type $aData['ordersummary'] ...

Thank you in advance

» Quick.Cart v6.x

boboo

Avatar: boboo

2014-02-15 06:31

In the listOrdersAdmin function directly under the "for" statement there is a line:

$aData $this->aOrders[$aOrders[$i]];


Exactly under this line we will calculate the order-summary using the generateProducts function:

$this->generateProducts($aData['iOrder'])


This function writes the order-summary into the class-variable "$this->fProductsSummary".
Now You can create a new "<td>" in the "content.=..." line and put as content this class-variable.
Something like this:


<td>'.$this->fProductsSummary.'</td>


The title of the column You have already created in You first post.
The fProductsSummary does NOT contain the payment and shipping costs.

boboo :-)

cachousam

Avatar: cachousam

2014-02-15 16:13

Thank you boboo.
It works perfectly.
I thought that when an order was recorded, all data were stored in a file, and it sufficed to get them and post them where you want.
Apparently this is not really the case.
For example, if I wanted to display the order total with shipping would it be possible?

I ask this because I created a variable purchase price in the page products editing and I will try with a formula to calculate the total margin on each order.
The display will also in the page orders editing and perhaps somewhere else.

So I would like to know a little more where the data is stored.

I love this script.

boboo

Avatar: boboo

2014-02-15 18:13

"So I would like to know a little more where the data is stored."
Then look into _fields.php in database folder.
There You can see where which variable is saved.
Ordered products and their prices in orders_products;
payments, shipping, comments in orders_ext.

The best way to calculate the total margin of order is to save the purchase price into the orders_products db, together with sales price.
So You can avoid mistakes if the price has been changed by editing product.

And,
if You really like the script, so trust me, it is a very good evening lecture in bed, instead of Harry Potter or sth else :-)

boboo :-)

cachousam

Avatar: cachousam

2014-02-15 21:46

oh yes.
I really like this script .I use it since version 3.
I do not have your knowledge, but I am very proud and after many hours of work and research,copy, paste, use notepad+ ,i have managed to make some very nice sites.
I do not like reading the harry potter style!!!!!
Very soon if I can do what I said in the third post.
Thank you also to those who share their knowledge.
Dominique from France.

cachousam

Avatar: cachousam

2014-02-16 10:03

Hello,
Here are my results for my function margin:

in database/translation/en.php i have put


       $lang
['Purchase_price'] = "Purchase price";
       
$lang['Margin'] = "Margin";



in database/_fields.php i have put



// database/xx_products.php fields - where xx is en, pl, cz etc.
$aProductsFields = Array( 'iProduct''sName''sNameUrl''mPrice''iStatus''iPosition',  'sAvailable''sNameTitle''sTemplate''sTheme''sMetaKeywords''sMetaDescription''sDescriptionShort''sDescriptionFull''fPurchaseprice' );

// database/orders_products.php fields
$aOrdersProductsFields = Array( 'iElement''iOrder''iProduct''iQuantity''fPrice''sName''fPurchaseprice' );



in the core/products-admin.php, in the public function saveProducts i have added


if( $aForm['aPrices'][$iProduct] != $aData['fPurchaseprice'] ){
            
$this->aProducts[$iProduct]['fPurchaseprice'] = $aForm['aPrices'][$iProduct];
            
$bChanged true;
          }
          



in the template/admin/products-form.php i have added this:



<input type="text" name="mPrice" value="<?php if( isset( $aData['mPrice'] ) ) echo $aData['mPrice']; ?>" class="inputr" size="10" /> <?php echo $config['currency_symbol']; ?>
            
            
            
            
            
            <?php echo $lang['Purchase_price']; ?><input type="text" name="fPurchaseprice"  value="<?php if( isset( $aData['fPurchaseprice'] ) ) echo $aData['fPurchaseprice']; ?>" class="inputr" size="10" alt="simple"/>





in template/admin/orders.php i have added this



<td class="date"><?php echo $lang['Date']; ?></td>
            
            
            
            
            <td class="summary"><?php echo $lang['Summary']; ?> [<?php echo $config['currency_symbol']; ?>]</td>
            <td class="summary"><?php echo $lang['Margin']; ?> </td>
            
            
            
            
            
            <td class="status"><?php echo $lang['Status']; ?></td>




in the core/orders-admin.php in the public function listOrdersAdmin i have added



for( $i $aKeys['iStart']; $i $aKeys['iEnd']; $i++ ){
        
$aData $this->aOrders[$aOrders[$i]];
        
        
        
        
        
        
$this->generateProducts($aData['iOrder']);
        
$this->calculmarginorder($aData['iOrder']);




and finally in the core/orders.php i have added this function:


/**
  * Generates a variable with products in an order for calculing the margin of the order
  * @return void
  * @param int  $iOrder
  */
  
public function calculmarginorder$iOrder ){
    
$rFile fopenDB_ORDERS_PRODUCTS'r' );
    
$i 0;
    
$this->fMarginOrder null;
    while( !
feof$rFile ) ){
      
$sContent fgets$rFile );
      if( 
$i && !empty( $sContent ) ){
        
$aData unserializetrim$sContent ) );
        if( 
$aData['iOrder'] == $iOrder ){
          
$this->aProducts[$aData['iElement']] = $aData;
          
$this->aProducts[$aData['iElement']]['fSummary'] = normalizePrice(( $this->aProducts[$aData['iElement']]['fPrice'] * $this->aProducts[$aData['iElement']]['iQuantity'])-( $this->aProducts[$aData['iElement']]['fPurchaseprice'] * $this->aProducts[$aData['iElement']]['iQuantity']) );
          
$this->fMarginOrder += ( $this->aProducts[$aData['iElement']]['fPrice'] * $this->aProducts[$aData['iElement']]['iQuantity'])-( $this->aProducts[$aData['iElement']]['fPurchaseprice'] * $this->aProducts[$aData['iElement']]['iQuantity']);
        }
      }
      
$i++;
    } 
// end while
    
fclose$rFile );

    if( isset( 
$this->fMarginOrder ) ){
      
$this->fMarginOrder normalizePrice$this->fMarginOrder );
    }
  } 
// end function calculmarginorder




All works but the result of the margin is not good.

cachousam

Avatar: cachousam

2014-02-16 10:07

If i replace in core /orders.php the line


$this
->aProducts[$aData['iElement']]['fSummary'] = normalizePrice(( $this->aProducts[$aData['iElement']]['fPrice'] * $this->aProducts[$aData['iElement']]['iQuantity'])-( $this->aProducts[$aData['iElement']]['fPurchaseprice'] * $this->aProducts[$aData['iElement']]['iQuantity']) );
          
$this->fMarginOrder += ( $this->aProducts[$aData['iElement']]['fPrice'] * $this->aProducts[$aData['iElement']]['iQuantity'])-( $this->aProducts[$aData['iElement']]['fPurchaseprice'] * $this->aProducts[$aData['iElement']]['iQuantity']);



by the line



$this
->aProducts[$aData['iElement']]['fSummary'] = normalizePrice(( $this->aProducts[$aData['iElement']]['fPrice'] * $this->aProducts[$aData['iElement']]['iQuantity'])-10);
          
$this->fMarginOrder += ( $this->aProducts[$aData['iElement']]['fPrice'] * $this->aProducts[$aData['iElement']]['iQuantity'])-10;



It's works fine.


Where is my mistake?

Thanks

cachousam

Avatar: cachousam

2014-02-16 10:09

Sorry, i tell you that the value of 10 is an example.

cachousam

Avatar: cachousam

2014-02-16 15:25

I have try this function to:


 
public function calculmarginorder$iOrder ){
    
$rFile fopenDB_ORDERS_PRODUCTS'r' );
    
$i 0;
    
$this->fMarginOrder null;
    while( !
feof$rFile ) ){
      
$sContent fgets$rFile );
      if( 
$i && !empty( $sContent ) ){
        
$aData unserializetrim$sContent ) );
        if( 
$aData['iOrder'] == $iOrder ){
          
$this->aProducts[$aData['iElement']] = $aData;
          
          
          
$this->aProducts[$aData['iElement']]['fSummary'] = normalizePrice$this->aProducts[$aData['iElement']]['fPrice'] * $this->aProducts[$aData['iElement']]['iQuantity'] );
          
$this->fProductsSummary += $this->aProducts[$aData['iElement']]['fPrice'] * $this->aProducts[$aData['iElement']]['iQuantity'];
          
          
          
          
$this->aProducts[$aData['iElement']]['fMargintotalorder'] = normalizePrice$this->aProducts[$aData['iElement']]['fPurchaseprice'] * $this->aProducts[$aData['iElement']]['iQuantity']);
          
$this->fMarginOrder += (($this->aProducts[$aData['iElement']]['fPrice'] * $this->aProducts[$aData['iElement']]['iQuantity']) - (  $this->aProducts[$aData['iElement']]['fPurchaseprice'] * $this->aProducts[$aData['iElement']]['iQuantity']));
        }
      }
      
$i++;
    } 
// end while
    
fclose$rFile );

    if( isset( 
$this->fMarginOrder ) ){
      
$this->fMarginOrder normalizePrice$this->fMarginOrder );



With this line in function generate basket


$this
->aProducts[$iProduct]['fMargintotalorder'] = normalizePrice$aData['fPurchaseprice'] * $aData['iQuantity'] );



Without good résult.

I must not be very far from the succes no?

In addition, I do not see how to store this value margin in the file orders-products.php If I have succeeded.


Assistance would be welcome.
Regards

cachousam

Avatar: cachousam

2014-02-18 06:56

Hello to all.
I come to you because I still can not get to run this function.
I'm not a slacker, and you see that when I ask for help, it was after many try by myself.
Please help me. This would allow me to know a little more of the structure of this wonderfull CMS.
I still believe in helping others.
Dominique

boboo

Avatar: boboo

2014-02-18 08:42

1. You have to move the fPurchasePrice through the basket. Not visible for the customer, but it is necessary to save it later with the order.
2.

if( $aForm['aPrices'][$iProduct] != $aData['fPurchaseprice'] ){
 
$this->aProducts[$iProduct]['fPurchaseprice'] = $aForm['aPrices'][$iProduct];
 
$bChanged true;
}


This piece of code will override the fPurchasePrice with fPrice.
The "column-array" $aForm['aPrices'] contains the fPrice values in the list view.

boboo :-)

cachousam

Avatar: cachousam

2014-02-18 11:27

Thank you boboo.

Your N°2 explains your N° 1 I think.

If I understand correctly, this piece of code I had created as described above in the file core/products-admin.php, in the public function saveProducts ,i must place it elsewhere too.
Can you tell me where and if my second function public function calculmarginorder is the good?

Thanks

boboo

Avatar: boboo

2014-02-18 13:01

This function is in my opinion unnecessary.
If You save the fPurchasePrice into Products_DB and over the Basket into Orders_Products_DB, so instead of calling 2 functions in the loop (for($i=$aKeys...)):

$this->generateProducts($aData['iOrder']);
$this->calculmarginorder($aData['iOrder']);


just put the functionality into the generateProducts function.
Analyse how this function fills the variables, and just add a new one e.g.:fMargin=fPrice-fPurchasePrice.
This shall be faster, beacause generateProducts reads already the orders_products_db, so if you have saved the fPurchasePrice into this DB, you have the direct access to this value, without reading the file once more.

boboo :-)

cachousam

Avatar: cachousam

2014-02-20 07:47

Hello,
I must be very tired right now.
I do not see in which function of core / order.php file, I have to put this:


if( $aForm['aPrices'][$iProduct] != $aData['fPurchaseprice'] ){
 
$this->aProducts[$iProduct]['fPurchaseprice'] = $aForm['aPrices'][$iProduct];
 
$bChanged true;
}



to save the purchase price in the basket?

savebasket or generatebasket or another? I have try the previous without résult.

Regards

Back to top
about us | contact