Forums / Managing Customers and Orders / Order Confirmation e-mail order by model

Order Confirmation e-mail order by model

Locked

Started by wmkenny on 15 Mar 2007, 3:40 PM · Views: 3,531

Results 1 to 9 of 9
This thread is locked. New replies are disabled.
15 Mar 2007, 3:40 PM
#1
wmkenny avatar

wmkenny

New Zenner

Join Date:
Mar 2007
Posts:
11
Plugin Contributions:
0

Order Confirmation e-mail order by model

I'm having a little problem getting the order confirm e-mail line items in model order. Modifying classes/order.php I can get the order display by model using an "order by" in the select stmt, but this is after the e-mail(physical selection order) is sent.

Can someone point me in the right direction to change the e-mail line items sort order.

Thanks,
Bill

22 Mar 2007, 6:07 PM
#2
wmkenny avatar

wmkenny

New Zenner

Join Date:
Mar 2007
Posts:
11
Plugin Contributions:
0

Re: Order Confirmation e-mail order by model

To date there have been 23 views, but zero replies. Thank you for looking. Maybe this is not a little problem after all.

I'm using the model number as a location within the store. The order confirmation e-mail will perform double duty as an order and as an organized by location pick list.

I need the order confirmation e-mail line items in order by model(location), anyone?

23 Mar 2007, 1:35 AM
#3
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Order Confirmation e-mail order by model

This might take time to work out ...

Everything is configured to maintain the order from shopping_cart to checkout to email to My Account to orders so the display remains the same ...

It would take awhile to work out all of the sort changes to make this work in this manner ...

You have the right idea ... :smile:

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

23 Mar 2007, 9:01 AM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: Order Confirmation e-mail order by model

Would it make sense to use the admin Packing Slip feature instead? This could be less intrusive to code because it deals with data already saved in the database rather than merely an array of data that hasn't been stored yet.

To do it in the storefront, you need to edit the create_add_products() element of the order class, and before looping through $this->products, you need to sort that array based on model number. A challenging task depending on your definition of challenging.

To do it for the admin packing-slip, edit the Admin order.php class and change the order-by clause on the query to the orders_products table, using something like this two-step approach:

/admin/packingslip.php
at the top of the code section, ie: line 22 or so, you'll see:```
require('includes/application_top.php');

add these two new lines above it:```
// added for sort-by-model-number:
define('PACKSLIPSORTBYMODEL', 'true');

and

/admin/includes/classes/order.php
around line 115:$orders_products = $db->Execute("select orders_products_id, products_id, products_name, products_model, products_price, products_tax, products_quantity, final_price, onetime_charges, product_is_free from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$order_id . "' order by orders_products_id");becomes:```
$orders_products = $db->Execute("select orders_products_id, products_id, products_name, products_model,
products_price, products_tax, products_quantity,
final_price, onetime_charges,
product_is_free
from " . TABLE_ORDERS_PRODUCTS . "
where orders_id = '" . (int)$order_id . "'
[B] order by " . (defined('PACKSLIPSORTBYMODEL') && PACKSLIPSORTBYMODEL=='true' ? "products_model" : "orders_products_id");
[/B]

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

26 Mar 2007, 6:38 PM
#5
wmkenny avatar

wmkenny

New Zenner

Join Date:
Mar 2007
Posts:
11
Plugin Contributions:
0

Re: Order Confirmation e-mail order by model

Thank you very much for your replies and advice.

Using the packing slip is not an option, need the order confirmation data along with the model(location). Also, the order confirm email is going to perform triple duty not double duty. Its going to be a turnaround document also. Allowing the customer to click order link from the confirm email and update any discrepancies from the printed order and the actual experience from the store(next bridge to cross).

My hat is off to the good Doctor for pointing me to the products array in the order class. I finally have the array sorted by model and the confirm email looks good.

Again Thanks :thumbsup:

6 Aug 2007, 1:05 AM
#6
marknew avatar

marknew

Zen Follower

Join Date:
Oct 2005
Posts:
274
Plugin Contributions:
0

Re: Order Confirmation e-mail order by model

Hi WmKenny,
I need exactly the same sorting for my order conformation email with a link back to edit the order. Could you post the code for sorting the products by model please?
Cheers.
M

6 Aug 2007, 11:03 AM
#7
wmkenny avatar

wmkenny

New Zenner

Join Date:
Mar 2007
Posts:
11
Plugin Contributions:
0

Re: Order Confirmation e-mail order by model

This will put the confirm email in model order. I haven't tackled the edit order return portion. If you have any success with updating the order from the confirm email please keep me posted.
The email confirm appears to be functioning properly here is the code:

//   S O R  T  A R R A Y

//foreach ($this->products['model'] as $key => $val) {
//   echo "$key = $val\n";

//}



//foreach ($this->products['model'] as $key => $val) {
//   echo "$key = $val\n";

//}






//print_r(array_values($this->products));







function SortDataSet($aArray, $sField, $bDescending = false)
{
   $bIsNumeric = IsNumeric($aArray);
   $aKeys = array_keys($aArray);
   $nSize = sizeof($aArray);

   for ($nIndex = 0; $nIndex < $nSize - 1; $nIndex++)
   {
       $nMinIndex = $nIndex;
       $objMinValue = $aArray[$aKeys[$nIndex]][$sField];
       $sKey = $aKeys[$nIndex];

       for ($nSortIndex = $nIndex + 1; $nSortIndex < $nSize; ++$nSortIndex)
       {
           if ($aArray[$aKeys[$nSortIndex]][$sField] < $objMinValue)
           {
               $nMinIndex = $nSortIndex;
               $sKey = $aKeys[$nSortIndex];
               $objMinValue = $aArray[$aKeys[$nSortIndex]][$sField];
           }
       }

       $aKeys[$nMinIndex] = $aKeys[$nIndex];
       $aKeys[$nIndex] = $sKey;
   }

   $aReturn = array();
   for($nSortIndex = 0; $nSortIndex < $nSize; ++$nSortIndex)
   {
       $nIndex = $bDescending ? $nSize - $nSortIndex - 1: $nSortIndex;
       $aReturn[$aKeys[$nIndex]] = $aArray[$aKeys[$nIndex]];
   }

   return $bIsNumeric ? array_values($aReturn) : $aReturn;
}

function IsNumeric($aArray)
{
   $aKeys = array_keys($aArray);
   for ($nIndex = 0; $nIndex < sizeof($aKeys); $nIndex++)
   {
       if (!is_int($aKeys[$nIndex]) || ($aKeys[$nIndex] != $nIndex))
       {
           return false;
       }
   }

   return true;
}


//$retval = array_multisort($this->products, SORT_ASC);
//uasort($this->products[model]);
//print_r(array_values($this->products));
//exit();


$ProdArray = $this->products;
$SortOrder = 0;

//var_dump(SortDataSet($ProdArray,'model',$SortOrder));


$BillArray = array();
$BillArray = SortDataSet($ProdArray,'model',$SortOrder);

//print_r(array_values($BillArray));

$this->products = $BillArray;

//exit();






 //     E N D    S O R T    A R R A Y
22 Aug 2007, 11:19 PM
#8
marknew avatar

marknew

Zen Follower

Join Date:
Oct 2005
Posts:
274
Plugin Contributions:
0

Re: Order Confirmation e-mail order by model

thanks for that.
Where/ which file do i add this code to?

8 Jan 2008, 1:47 PM
#9
wmkenny avatar

wmkenny

New Zenner

Join Date:
Mar 2007
Posts:
11
Plugin Contributions:
0

Re: Order Confirmation e-mail order by model

Dr. Byte told me where to put the sort (from his reply above) ...

To do it in the storefront, you need to edit the create_add_products() element of the order class, and before looping through $this->products, you need to sort that array based on model number. A challenging task depending on your definition of challenging.

So I placed the sort array (posted above) where Dr. Byte suggested which prompted my reply ...

My hat is off to the good Doctor for pointing me to the products array in the order class. I finally have the array sorted by model and the confirm email looks good.

Hope this helps, Good Luck.