Results 1 to 9 of 9
  1. #1
    Join Date
    Mar 2007
    Posts
    11
    Plugin Contributions
    0

    cart error 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

  2. #2
    Join Date
    Mar 2007
    Posts
    11
    Plugin Contributions
    0

    cart error 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?

  3. #3
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default 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 ...
    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: v1.5.5]
    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!

  4. #4
    Join Date
    Jan 2004
    Posts
    66,364
    Blog Entries
    7
    Plugin Contributions
    274

    Default 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:
    Code:
     require('includes/application_top.php');
    add these two new lines above it:
    Code:
    // added for sort-by-model-number:
    define('PACKSLIPSORTBYMODEL', 'true');
    and

    /admin/includes/classes/order.php
    around line 115:
    Code:
          $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:
    Code:
          $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 " . (defined('PACKSLIPSORTBYMODEL') && PACKSLIPSORTBYMODEL=='true' ? "products_model" : "orders_products_id");
    
    .

    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.

  5. #5
    Join Date
    Mar 2007
    Posts
    11
    Plugin Contributions
    0

    Default 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

  6. #6
    Join Date
    Oct 2005
    Posts
    286
    Plugin Contributions
    0

    Default 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

  7. #7
    Join Date
    Mar 2007
    Posts
    11
    Plugin Contributions
    0

    Default 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:
    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

  8. #8
    Join Date
    Oct 2005
    Posts
    286
    Plugin Contributions
    0

    Default Re: Order Confirmation e-mail order by model

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

  9. #9
    Join Date
    Mar 2007
    Posts
    11
    Plugin Contributions
    0

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

 

 

Similar Threads

  1. Order Confirmation E-mail
    By Adds in forum General Questions
    Replies: 1
    Last Post: 28 Nov 2007, 11:12 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR