Page 1 of 2 12 LastLast
Results 1 to 10 of 13
  1. #1
    Join Date
    Jan 2010
    Posts
    182
    Plugin Contributions
    0

    Default Auto update Order Status via barcode on invoice

    1.3.8a - I know, we are upgrading soon

    The code I'm working on should auto update the order_status when a barcode on an invoice is scanned into a text box.

    I have placed this in admin/includes/header.php as I would like it visible always and mainly viewing admin home.
    Also have "admin home" refresh when the order is updated with the cursor always ready to go in that checkbox if initially clicked there.

    Here's the code I have based on super_orders id text box though a bit stuck. While in super_orders viewing an order, it's changing the dropdown to order_status 2? The input_field itself does nothing up in the header.
    Any suggestions?

    PHP Code:
    <?php
            
    echo zen_draw_input_field('oID''''size="6"');
                    echo 
    zen_draw_hidden_field('oID'$oID);
                
    $db->Execute("UPDATE " TABLE_ORDERS " SET orders_status_id='2' where orders_id='".$oID."'");
                    echo 
    '</form>'?>

  2. #2
    Join Date
    Jan 2010
    Posts
    182
    Plugin Contributions
    0

    Default Re: Auto update Order Status via barcode on invoice

    I have recoded this, which breaks the behavior of the status displaying "2" in the dropdown menu.

    I do think this is the wrong direction as I believe the previous code was actually updating the order to status "2", but not updating the order status history that is desired.

    Thoughts?

    PHP Code:
    <?php
                      
    echo zen_draw_form('auto_update''/index.php''''get'''true);
                      echo 
    zen_draw_input_field('auto_update''''size="6"');
                      echo 
    zen_draw_hidden_field('auto_update'$oID);
                     
    ?>
                     <?php
                      
    {
            if(isset(
    $_POST['auto_update']) ){ 
                      
    $orders_history $db->Execute("UPDATE ".TABLE_ORDERS." SET orders_status='4' where orders_id='".$oID."'");
                                               }
                      }
                      
    ?>
                      <?php
                      
    echo '</form>'?>

  3. #3
    Join Date
    Jan 2007
    Posts
    1,484
    Plugin Contributions
    10

    Default Re: Auto update Order Status via barcode on invoice

    Hmmm, I like where you are going with this since we are about to add barcodes to our warehouse fulfillment process and auto updating by scanning a barcode would be nice. But I would want it to send the email, too, so there's more to it than that. I'll have a think about this and try a few things out this coming weekend. I don't have time during the week to work on much code development anymore. Thanks for getting the conversation started!

    Zen Cart and it's community are the best!!

  4. #4
    Join Date
    Jan 2010
    Posts
    182
    Plugin Contributions
    0

    Default Re: Auto update Order Status via barcode on invoice

    excellent great hopeful move forward - default behavior of the comments is that the email notification is set to true. I have changed that to false.

    Where I am stuck is that the 1st post is more correct - it needs the following to update the page and engage the form field.
    PHP Code:
    echo zen_draw_form('auto_update''/index.php''''get'''true); 
    The code is making the dropdown status update to that status, just not updating the status_history. When I swap table_orders for table_orders_status_history and orders_status to include _id, ALL the previous statuses change to that ID.

    It needs to still update the order and INSERT a new status as if I hit the update button on super_orders
    PHP Code:
    <?php echo zen_image_submit('button_update.gif'IMAGE_UPDATE); ?>
    After the page refreshes, the cursor disappears from the form. Would need it to stay there ready to accept another scan.

    Automation is the key to expediency!

  5. #5
    Join Date
    Jan 2010
    Posts
    182
    Plugin Contributions
    0

    Default Re: Auto update Order Status via barcode on invoice

    For the barcode, I used this and it was extremely easy and effective

    http://www.ladyada.net/library/zencart/barcodeinv.html

    We currently use it in super_orders for the shipper to "bleep" the order in and go to that order instantaneously.

  6. #6
    Join Date
    Jan 2010
    Posts
    182
    Plugin Contributions
    0

    Default Re: Auto update Order Status via barcode on invoice

    Very frustrating - I got this to work minus having the order_status_name appear in the history, it was a blank box.

    Now that I come back to it later tonight - nothing works at all - what gives?!

    PHP Code:
    <td align="left" valign="middle"><?php
                      
    echo zen_draw_form('auto_update''/index.php''''get'''true);
                      echo 
    zen_draw_input_field('auto_update''''size="6"');
                      echo 
    zen_draw_hidden_field('auto_update'$oID);
                      
    // the order status name is blank on the update
            
    if(isset($_POST['oID']) ){ 
                      
    $orders_status $db->Execute("UPDATE " TABLE_ORDERS " SET orders_status='4' where orders_id='" $oID "'");
                      
                      
    $orders_status_history $db->Execute("INSERT into " TABLE_ORDERS_STATUS_HISTORY "
                          (orders_id, orders_status_id, date_added, customer_notified, comments)
                          values ('" 
    . (int)$oID "',
                          '" 
    zen_db_input($status) . "',
                          now(),
                          '" 
    zen_db_input($customer_notified) . "',
                            (SELECT IFNULL(admin_initials, '') FROM admin WHERE admin_id='" 
    .$_SESSION["admin_id"] ."'))");            
                      }
                      
    ?>
                      <?php
                      
    echo '</form>'?>
                    <br />Update to Pulled</td>
        </td>

  7. #7
    Join Date
    Jan 2010
    Posts
    182
    Plugin Contributions
    0

    Default Re: Auto update Order Status via barcode on invoice

    ANSWER - POST needs to be GET

    It works again.

    So anyone know why the order_status_name is not populating upon the update?

  8. #8
    Join Date
    Jan 2010
    Posts
    182
    Plugin Contributions
    0

    Default Re: Auto update Order Status via barcode on invoice

    I have gone as far as making a brand new module for this and have plans to contribute it as well.

    I have everything set up and done except one measly hurdle.
    The problem lies in after the order is auto-updated, the orders_status_name is blank on the order history - what am I overlooking here?
    The variable $status is there, but it should be defined as the newly updated orders_status='4'
    So $status = 'what'
    I tried $status = "Order Pulled"; as a fall back and it did not work

    PHP Code:
        $db->Execute("INSERT into " TABLE_ORDERS_STATUS_HISTORY "
                          (orders_id, orders_status_id, date_added, customer_notified, comments)
                          values ('" 
    . (int)$order_no "',
                          '" 
    zen_db_input($status) . "',
                          now(),
                          '" 
    zen_db_input($customer_notified) . "',
                          (SELECT IFNULL(admin_initials, '') FROM admin WHERE admin_id='" 
    .$_SESSION["admin_id"] ."'))"); 

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

    Default Re: Auto update Order Status via barcode on invoice

    In your prior post you are hard-coding a value of 4 for the new status in the prior query (the UPDATE statement). If you're relying on hard-coding numbers like thatn, then you'll need to do it consistently. So, either use a variable (like maybe $status if using it doesn't clash with other things already being done in original code, or pick something else) and use it in all relevant places, or hard-code it consistently in all relevant places.
    .

    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.

  10. #10
    Join Date
    Jan 2010
    Posts
    182
    Plugin Contributions
    0

    Default Re: Auto update Order Status via barcode on invoice

    hmm... I was unaware of how to code that section orders_status='4' differently. Here is the entire block...

    PHP Code:
    <?php
        $auto_update 
    false
        if (
    $auto_update == false) {
            if(isset(
    $_POST['order_no'])) {
                      
                      
    $auto_update zen_db_prepare_input($_POST['order_no']); 
                      
                      
    $db->Execute("UPDATE " TABLE_ORDERS 
                                      SET orders_status='4', last_modified = now()
                                      where orders_id='" 
    $order_no "'");
                      
                      
    $db->Execute("INSERT into " TABLE_ORDERS_STATUS_HISTORY "
                          (orders_id, orders_status_id, date_added, customer_notified, comments)
                          values ('" 
    . (int)$order_no "',
                          '" 
    zen_db_input($status) . "',
                          now(),
                          '" 
    zen_db_input($customer_notified) . "',
                          (SELECT IFNULL(admin_initials, '') FROM admin WHERE admin_id='" 
    .$_SESSION["admin_id"] ."'))");
                            
                      
    zen_redirect(zen_href_link(FILENAME_AUTOUPDATE'''SSL'));                
                      }
                     } 
    ?>
    I don't mind hard coding '" . zen_db_input($status) . "', to be the order_status='4', but unsure how to tackle that.
    I tried $status = "Order Pulled"; as a variable and that didn't work.

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. v154 Scan Barcode > Post Order Update
    By ShopVille in forum General Questions
    Replies: 14
    Last Post: 12 Sep 2015, 02:41 AM
  2. Can you auto update the order status?
    By ricky_moore in forum Managing Customers and Orders
    Replies: 3
    Last Post: 11 Jan 2011, 05:35 PM
  3. Change Email Subject of Status Update Messages e.g. Order Update XXXX
    By apemusic in forum Managing Customers and Orders
    Replies: 4
    Last Post: 13 Oct 2010, 08:42 AM
  4. Auto Order Status update?
    By Diddyo in forum General Questions
    Replies: 3
    Last Post: 25 Jul 2010, 05:14 AM
  5. invoice deleted on update of status
    By alghazn in forum Managing Customers and Orders
    Replies: 5
    Last Post: 2 Nov 2007, 09:55 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