Results 1 to 9 of 9
  1. #1
    Join Date
    Oct 2004
    Posts
    1,045
    Plugin Contributions
    0

    Default Confirmation E-mail - Sort products by manufacturer?

    I can get the manufacturer to show up for each product in the order confirmation e-mail, but I would like to go beyond that and have the products display in order of manufacturer, so that all the products from one manufacturer are together. I'm just not sure how to go about this. I thought of going all the way back to the cart and doing the sort there, but I played around a bit and am not sure how to do that either
    Danielle

  2. #2
    Join Date
    Jul 2012
    Posts
    16,733
    Plugin Contributions
    17

    Default Re: Confirmation E-mail - Sort products by manufacturer?

    Quote Originally Posted by Danielle View Post
    I can get the manufacturer to show up for each product in the order confirmation e-mail, but I would like to go beyond that and have the products display in order of manufacturer, so that all the products from one manufacturer are together. I'm just not sure how to go about this. I thought of going all the way back to the cart and doing the sort there, but I played around a bit and am not sure how to do that either
    The cart order display basically has been put together to give a top down view of product addition such that newly added product go towards the bottom.

    What you would likely want to do say just before processing to display/output the cart contents is to first determine what the sort order of each product should be then create a temporary cart that is to receive the content of each of the product and add the product from the live cart to the temporary cart in the desired order, then process the display using the temporary cart. An alternative could be to maintain two different cart values such that whenever something is added to the main cart it is added to this other cart variable but in a sorted manner (even if it means after an add to resort the array).

    The only thing that I can see as a concern is where in the process is this to be introduced because might it not cause confusion if say the sequence has been changed during checkout making the customer second guess site operation? If it's for some report or offered as a sort option when viewing the cart contents I get it, but not sure otherwise.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  3. #3
    Join Date
    Nov 2005
    Location
    los angeles
    Posts
    2,690
    Plugin Contributions
    9

    Default Re: Confirmation E-mail - Sort products by manufacturer?

    hi danielle,
    to change the sort for ONLY the email confirmation, you need to modify the following code in includes/classes/order.php:

    Code:
        $orders_products_query = "select orders_products_id, products_id, products_name,
                                     products_model, products_price, products_tax,
                                     products_quantity, final_price,
                                     onetime_charges,
                                     products_priced_by_attribute, product_is_free, products_discount_type,
                                     products_discount_type_from
                                      from " . TABLE_ORDERS_PRODUCTS . "
                                      where orders_id = '" . (int)$order_id . "'
                                      order by orders_products_id";
    in version 155e, this starts on line 168. you can change the code to:

    Code:
    $orders_products_query = "select orders_products_id, op.products_id, op.products_name,
        op.products_model, op.products_price, products_tax,
        op.products_quantity, op.final_price,
        onetime_charges, p.manufacturers_id,
        op.products_priced_by_attribute, op.product_is_free, op.products_discount_type,
        op.products_discount_type_from
        from " . TABLE_ORDERS_PRODUCTS . " op
        left join " . TABLE_PRODUCTS . " p on op.products_id = p.products_id
        where orders_id = '" . (int)$order_id . "'
        order by p.manufacturers_id";
    good luck!
    author of square Webpay.
    mxWorks has premium plugins. donations: venmo or paypal accepted.
    premium consistent excellent support. available for hire.

  4. #4
    Join Date
    Oct 2004
    Posts
    1,045
    Plugin Contributions
    0

    Default Re: Confirmation E-mail - Sort products by manufacturer?

    Quote Originally Posted by carlwhat View Post
    hi danielle,
    to change the sort for ONLY the email confirmation, you need to modify the following code in includes/classes/order.php:

    Code:
        $orders_products_query = "select orders_products_id, products_id, products_name,
                                     products_model, products_price, products_tax,
                                     products_quantity, final_price,
                                     onetime_charges,
                                     products_priced_by_attribute, product_is_free, products_discount_type,
                                     products_discount_type_from
                                      from " . TABLE_ORDERS_PRODUCTS . "
                                      where orders_id = '" . (int)$order_id . "'
                                      order by orders_products_id";
    in version 155e, this starts on line 168. you can change the code to:

    Code:
    $orders_products_query = "select orders_products_id, op.products_id, op.products_name,
        op.products_model, op.products_price, products_tax,
        op.products_quantity, op.final_price,
        onetime_charges, p.manufacturers_id,
        op.products_priced_by_attribute, op.product_is_free, op.products_discount_type,
        op.products_discount_type_from
        from " . TABLE_ORDERS_PRODUCTS . " op
        left join " . TABLE_PRODUCTS . " p on op.products_id = p.products_id
        where orders_id = '" . (int)$order_id . "'
        order by p.manufacturers_id";
    good luck!
    Thank you, unfortunately it didn't work.
    Danielle

  5. #5
    Join Date
    Nov 2005
    Location
    los angeles
    Posts
    2,690
    Plugin Contributions
    9

    Default Re: Confirmation E-mail - Sort products by manufacturer?

    danielle,
    can you be more specific? did the email come in, and the products were the same as the way it was placed? or did you not get an order confirmation email?

    this would NOT change the order of how the products get displayed on the admin side.

    thanks.
    author of square Webpay.
    mxWorks has premium plugins. donations: venmo or paypal accepted.
    premium consistent excellent support. available for hire.

  6. #6
    Join Date
    Oct 2004
    Posts
    1,045
    Plugin Contributions
    0

    Default Re: Confirmation E-mail - Sort products by manufacturer?

    Quote Originally Posted by carlwhat View Post
    danielle,
    can you be more specific? did the email come in, and the products were the same as the way it was placed? or did you not get an order confirmation email?

    this would NOT change the order of how the products get displayed on the admin side.

    thanks.
    The e-mail came, but the products in it were not sorted.
    Danielle

  7. #7
    Join Date
    Nov 2005
    Location
    los angeles
    Posts
    2,690
    Plugin Contributions
    9

    Default Re: Confirmation E-mail - Sort products by manufacturer?

    wow.... lot of work...

    danielle, please confirm what version of zen-cart you are on as well as your php version.

    in addition, the "easy" way to do this is to sort all of the products PRIOR to creating the order. the creation of entries into the orders_products table happens at the same time that the email gets generated. if you want the order to have the products sorted the default way (based on the entry into the cart), and the email sorted differently, then that is more work....

    best.
    author of square Webpay.
    mxWorks has premium plugins. donations: venmo or paypal accepted.
    premium consistent excellent support. available for hire.

  8. #8
    Join Date
    Oct 2004
    Posts
    1,045
    Plugin Contributions
    0

    Default Re: Confirmation E-mail - Sort products by manufacturer?

    Quote Originally Posted by carlwhat View Post
    wow.... lot of work...

    danielle, please confirm what version of zen-cart you are on as well as your php version.

    in addition, the "easy" way to do this is to sort all of the products PRIOR to creating the order. the creation of entries into the orders_products table happens at the same time that the email gets generated. if you want the order to have the products sorted the default way (based on the entry into the cart), and the email sorted differently, then that is more work....

    best.
    It is Zen-Cart 1.5.5e and PHP 7.0.12.

    The order and e-mail can be sorted the same, I was wondering about that as I also thought the e-mail was generated right at the same time.
    Danielle

  9. #9
    Join Date
    Nov 2005
    Location
    los angeles
    Posts
    2,690
    Plugin Contributions
    9

    Default Re: Confirmation E-mail - Sort products by manufacturer?

    ok, here we go.... no guarantees!

    restore the original code from my changes above!

    includes/classes/order.php line 464, we are adding 1 line:
    Code:
                                          'id' => $products[$i]['id'],
                                          'manufacturers_id' => $products[$i]['manufacturers_id'],
                                          'rowClass' => $rowClass);
    line 719 (or thereabouts), add another line:

    Code:
        $this->email_low_stock='';
        
        usort($this->products, "manuf_cmp");
    
        for ($i=0, $n=sizeof($this->products); $i<$n; $i++) {
    in includes/classes/shopping_cart.php on 1206:

    Code:
        $products_array = array();
        reset($this->contents);
        while (list($products_id, ) = each($this->contents)) {
          $products_query = "select p.products_id, p.master_categories_id, p.products_status, pd.products_name, p.products_model, p.products_image,
                                      p.products_price, p.products_weight, p.products_tax_class_id,
                                      p.products_quantity_order_min, p.products_quantity_order_units, p.products_quantity_order_max,
                                      p.product_is_free, p.products_priced_by_attribute, p.manufacturers_id, 
                                      p.products_discount_type, p.products_discount_type_from, p.products_virtual, p.product_is_always_free_shipping
                               from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
                               where p.products_id = '" . (int)$products_id . "'
                               and pd.products_id = p.products_id
                               and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'";
    finally a new file:

    includes/extra_datafiles/my_mods.php

    Code:
    function manuf_cmp($a, $b)
    {
        return $a['manufacturers_id'] - $b['manufacturers_id'];
    }
    let us know how it goes!

    note, this will sort based on the numerical value of the key assigned to the manufacturer. not the manufacturers name....

    best.
    author of square Webpay.
    mxWorks has premium plugins. donations: venmo or paypal accepted.
    premium consistent excellent support. available for hire.

 

 

Similar Threads

  1. v153 Manufacturer sort in default sort drop down
    By vacuumwarlock in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 24 Nov 2014, 02:58 PM
  2. Sort by Manufacturer... SLOW!
    By DigitalShadow in forum General Questions
    Replies: 5
    Last Post: 23 Jun 2010, 06:35 PM
  3. sort by manufacturer
    By etoile03 in forum Customization from the Admin
    Replies: 1
    Last Post: 5 Nov 2006, 06:33 PM
  4. E-mail Text on Confirmation e-mail
    By beth99 in forum General Questions
    Replies: 3
    Last Post: 18 Sep 2006, 02:37 AM

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