Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2006
    Posts
    199
    Plugin Contributions
    0

    Default Order Pull Sheet Almost Ready. Could use a hand.

    I have a quick little modification/add-on almost ready. It creates a simple report that is in a table format ready for printing. It starts with a dropdown for order status. Select the status you need and it populates a long table with the order number, delivery name and address, and then the products in the order. It can be printed out to create a "pull sheet" for those of us who prefer to work from a sheet in the warehouse that's not the packing slip. (My warehouse is wet and dirty. I don't want my packing slips out there). It will print the necessary information for dozens of orders on just a couple of pages; saving space and paper. Might also be useful for drop shippers who use order status in unusual ways like I do.
    Anyway, it's almost ready. I have just 1 problem in the code. Everything formats beautifully but the products in each order. Only the products for the very first order in the database appear and they appear for every order.
    I'm sure I'm just asking for the products the wrong way and could use some help to tweak the code. I'm going to include it because it's a fairly short file. The part asking for the products is:
    PHP Code:
    $order = new order($orders);
        for (
    $i=0$n=sizeof($order->products); $i<$n$i++) {
          echo  
    $order->products[$i]['qty'] . '&nbsp;' $order->products[$i]['name']; 
    and the whole file is here:

    PHP Code:
    <?php
    require('includes/application_top.php');
    include(
    DIR_WS_CLASSES 'order.php');  

      
    // prepare order-status pulldown list
      
    $orders_statuses = array();
      
    $orders_status_array = array();
      
    $orders_status $db->Execute("select orders_status_id, orders_status_name
                                     from " 
    TABLE_ORDERS_STATUS "
                                     where language_id = '" 
    . (int)$_SESSION['languages_id'] . "'");
      while (!
    $orders_status->EOF) {
        
    $orders_statuses[] = array('id' => $orders_status->fields['orders_status_id'],
                                   
    'text' => $orders_status->fields['orders_status_name'] . ' [' $orders_status->fields['orders_status_id'] . ']');
        
    $orders_status_array[$orders_status->fields['orders_status_id']] = $orders_status->fields['orders_status_name'];
        
    $orders_status->MoveNext();
      }

      
    $action = (isset($_GET['action']) ? $_GET['action'] : '');
      
    $order_exists false;
      if (isset(
    $_GET['oID']) && trim($_GET['oID']) == '') unset($_GET['oID']);
      if (
    $action == 'edit' && !isset($_GET['oID'])) $action '';

      if (isset(
    $_GET['oID'])) {
        
    $oID zen_db_prepare_input(trim($_GET['oID']));

        
    $orders $db->Execute("select orders_id from " TABLE_ORDERS "
                                where orders_id = '" 
    . (int)$oID "'");
        
    $order_exists true;
        if (
    $orders->RecordCount() <= 0) {
          
    $order_exists false;
          if (
    $action != ''$messageStack->add(sprintf(ERROR_ORDER_DOES_NOT_EXIST$oID), 'error');
        }
      }

    $order_status $select_order_status;
    $display_order_status $order_status;
    if (
    $order_status == "")
            {
            
    $order_status 1;
            }
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>OrderList</title>
    </head>
    <body>
    <h1>Orderlist</h1><br>
     <script language="javascript">
    <!--
    document.write(Date());
    -->
    </script>
    <h2>
                  <tr><?php echo zen_draw_form('status'orderlist'''get'''true); ?>
                    <td class="smallText" align="right">
                      <?php
                        
    echo "Choose Status:" ' ' zen_draw_pull_down_menu('status'array_merge(array(array('id' => '''text' => "All")), $orders_statuses), $_GET['status'], 'onChange="this.form.submit();"');
                        echo 
    zen_hide_session_id();
                      
    ?>
                    </td>
                  </form></tr>
    </h2>

    <TABLE width="100%" align=center cellSpacing=1 cellPadding=1 border=1>
      <?php
    if ($_GET['status'] != '') {
          
    $status zen_db_prepare_input($_GET['status']);
          
    $orders_query_raw "select o.orders_id, o.customers_id, o.delivery_name, o.delivery_street_address, o.delivery_city, o.delivery_state,  o.delivery_postcode, o.customers_email_address, o.date_purchased,o.last_modified, o.currency_value, s.orders_status_name, ot.text as order_total" .
                              
    $new_fields "
                              from (" 
    TABLE_ORDERS " o, " .
                              
    TABLE_ORDERS_STATUS " s " .
                              
    $new_table ")
                              left join " 
    TABLE_ORDERS_TOTAL " ot on (o.orders_id = ot.orders_id) " "
                              where o.orders_status = s.orders_status_id and s.language_id = '" 
    . (int)$_SESSION['languages_id'] . "' and s.orders_status_id = '" . (int)$status "' and ot.class = 'ot_total'  " .
                              
    $search " order by o.orders_id ASC";
        }
        
     
    $orders $db->Execute($orders_query_raw);
        while (!
    $orders->EOF) {
        if ((!isset(
    $_GET['oID']) || (isset($_GET['oID']) && ($_GET['oID'] == $orders->fields['orders_id']))) && !isset($oInfo)) {
            
    $oInfo = new objectInfo($orders->fields);
          }

          if (isset(
    $oInfo) && is_object($oInfo) && ($orders->fields['orders_id'] == $oInfo->orders_id)) {
            echo 
    '              <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' zen_href_link(FILENAME_ORDER_EDITzen_get_all_get_params(array('oID''action')) . 'oID=' $oInfo->orders_id '&action=edit''NONSSL') . '\'">' "\n";
          } else {
            echo 
    '              <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' zen_href_link(FILENAME_ORDER_EDITzen_get_all_get_params(array('oID')) . 'oID=' $orders->fields['orders_id'], 'NONSSL') . '\'">' "\n";
          }

    ?>
                    <td class="dataTableContent" align="center" width="60"><?php echo  $orders->fields['orders_id']; ?></td>
                    <td class="dataTableContent" align="center" width="70"> S  H  P D </td>
                    <td class="dataTableContent"><?php echo $orders->fields['delivery_name'] . '<br />' $orders->fields['delivery_street_address'] . '<br />' $orders->fields['delivery_state'] . $orders->fields['delivery_postcode']  . '<br />' $orders->fields['customers_email_address'] ; ?></td>
                    <td class="dataTableContent" align="left">&nbsp;<?php
    $order 
    = new order($orders);
        for (
    $i=0$n=sizeof($order->products); $i<$n$i++) {
          echo  
    $order->products[$i]['qty'] . '&nbsp;' $order->products[$i]['name'];
        }
    ?></td>
                  </tr>
    <?php
          $orders
    ->MoveNext();
        }
    ?>
    </table>
    </body>
    </html>
    I think this will be useful for plenty of zenners and hope someone can clear up that one bit for me. Thanks!

  2. #2
    Join Date
    Aug 2004
    Location
    Belfast, Northern Ireland
    Posts
    2,480
    Plugin Contributions
    14

    Default Re: Order Pull Sheet Almost Ready. Could use a hand.

    Hi Dan,

    I think the problem is probably:

    PHP Code:
    $order = new order($orders); 
    I'd say it should be:

    PHP Code:
    $order = new order($orders->fields['orders_id']); 
    Hope that helps!

    Actually, you should also format the product output a bit better and if your store uses attributes you'll have to add code to output the attribute information for any applicable products.

    Here's a rough and ready example of better formatting of the products (no attribute code included):

    PHP Code:
    echo  '<p>' $order->products[$i]['qty'] . '&nbsp;' $order->products[$i]['name'] . '</p>'
    All the best...

    Conor
    Ceon
    Last edited by conor; 14 Mar 2009 at 05:51 PM.

  3. #3
    Join Date
    Dec 2006
    Posts
    199
    Plugin Contributions
    0

    Default Re: Order Pull Sheet Almost Ready. Could use a hand.

    That's perfect, Conor! As always, thank you for your help! When I get my head above water with shipping, I'll see about releasing this as an Add-On. It will make a huge difference for me and i hope it will help others here.

  4. #4
    Join Date
    Dec 2006
    Posts
    199
    Plugin Contributions
    0

    Default Re: Order Pull Sheet Almost Ready. Could use a hand.

    Cheers!

 

 

Similar Threads

  1. ready to pull my hair out
    By ccembd in forum General Questions
    Replies: 6
    Last Post: 26 May 2008, 08:25 AM
  2. Almost Ready to Go Live?
    By wingedwench in forum General Questions
    Replies: 5
    Last Post: 10 Jun 2007, 03:35 AM
  3. [B]Please help, I am ready to pull my hair out!!!![/B]
    By GoldBuckle in forum Templates, Stylesheets, Page Layout
    Replies: 15
    Last Post: 15 Mar 2007, 04:09 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