Title: Update Status Timeout
Last modified: August 21, 2016

---

# Update Status Timeout

 *  Resolved [olehellhound](https://wordpress.org/support/users/olehellhound/)
 * (@olehellhound)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/update-status-timeout/)
 * Here’s the rundown-
 * I have created a plugin which displays all orders in a nice format for a bakery
   using Flexigrid. The display works just fine. The problem is that I have a button
   at the end of each order row that will allow the shop manager to update an order
   status. All this is in the admin panel. Here is the code:
 *     ```
       function wc_mark_sg_order_complete($order_id){
       	global $woocommerce;
       	if (!$order_id) die;
       	$order = new WC_Order($order_id);
       	//$order->payment_complete();
       	$order->update_status( 'completed' );
   
       	wp_safe_redirect( wp_get_referer() );
       }
       add_action('wp_woocommerce_sg-mark-order-complete', 'wc_mark_sg_order_complete');
   
       if(!empty($_GET["orderComplete"])){
       	do_action('wp_woocommerce_sg-mark-order-complete', $_GET["orderComplete"]);
       }
       ```
   
 * This code _works_. The problem is the time it takes for the code to work. When
   I update an order status on the Woocommerce orders page, the status is updated
   near-instantly. When I use this function to update an order status, it will take
   exactly 60 seconds to complete. Something here is not ending the call to the 
   database or something I feel like. While the script is running, the entire database
   is locked and I cannot load the website in any other tabs until the action is
   completed. The database puts the query in to “Sleep” mode, I’m not sure if this
   has anything to do with it or not.
 * Basically, I just need to figure out how to get the code to execute instantly
   instead of taking the timeout period of 60 seconds to complete.
 * Thanks for any assistance! It is much appreciated!
 * [http://wordpress.org/plugins/woocommerce/](http://wordpress.org/plugins/woocommerce/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [olehellhound](https://wordpress.org/support/users/olehellhound/)
 * (@olehellhound)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/update-status-timeout/#post-4344308)
 * Update:
 * I removed all that code and replaced my “Complete Order” link href to this variable:
 * `$sg_url = wp_nonce_url( admin_url( 'admin-ajax.php?action=woocommerce-mark-order-
   complete&order_id=' . $the_order["orderid"] ), 'woocommerce-mark-order-complete');`
 * The same thing happened though. When I click the complete button in my plugin
   the script takes 60 seconds to execute but when I click the complete button from
   the WooCommerce orders page it will process instantly.
 * Thanks again for any assistance.
 *  Thread Starter [olehellhound](https://wordpress.org/support/users/olehellhound/)
 * (@olehellhound)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/update-status-timeout/#post-4344312)
 * Alrighty folks, it turns out that the emails for “Completed Orders” was causing
   the script to hang because I noticed the WooCommerce Orders page doing the same
   exact thing. I disabled email notices for Completed Orders and the script runs
   instantly.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Update Status Timeout’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

 * 2 replies
 * 1 participant
 * Last reply from: [olehellhound](https://wordpress.org/support/users/olehellhound/)
 * Last activity: [12 years, 6 months ago](https://wordpress.org/support/topic/update-status-timeout/#post-4344312)
 * Status: resolved