Orderable

Orderable – A WordPress Restaurant Plugin Tutorial

With Orderable, you can easily create a professional and elegant online menu for your restaurant that will help you increase sales and better serve your customers. In this tutorial, I’ll show you how to install and configure the plugin, add menu items and categories, and customise the look and feel of your menu.

Automatically set the Order Status for Orderable

  1. Got to Orderable->Order Statuses->Add New
  2. Enter ‘Pre-order’ as title
  3. Tick enabled
  4. Status Type as Custom
  5. Slug, should already fill-out to be ‘pre-order’
  6. Choose your preferred Colour and Icon
  7. Hit Publish
  8. Add the second status with the title of ‘Preparing’
  9. Tick enabled
  10. Status Type as Processing
  11. Slug, should already fill-out to be ‘processing’
  12. Choose your preferred Colour and Icon
  13. Hit Publish

Next, install the Code Snippets plugin by:

  • Plugins->Add New and searching for ‘Code Snippets’
  • Press Install and then Activate
  • When active an extra menu item will be on the main WordPress dashboard list called ‘Snippets’
  • Select Snippets->Add New
  • Give the code snippet a title
  • Copy the below code into the Functions editor
  • Scroll down to ‘Save Changes and Activate

The order statuses will now automatically change to ‘Preparing’ if due within the next 24 hours, anything over this and the order will be set to ‘Pre-Order’.

/**
* Auto Pre Order all WooCommerce orders.
*/
function custom_woocommerce_auto_status_order( $order_id ) {
    if ( ! $order_id ) {
        return;
    }

    $order = wc_get_order( $order_id );
    if( 'processing'== $order->get_status() ) {
		
		$nowtime = date("Y-m-d H:i:s"); 							// Today's date and time
		$date = date('Y-m-d H:i:s', strtotime($nowtime . ' + 24 hours'));			// Add 24 hours to today's date and time
		$orderBy = date('Y-m-d H:i:s' , $order->get_meta( '_orderable_order_timestamp' )); 	// Orderable delivery timestamp
		
		if ($orderBy > $date) {
			$order->update_status( 'pre-order' ); 				// If order is over 24hrs then set as a pre-order
		}
		else {
			$order->update_status( 'processing' ); 						// else set as Order -processing
		}
	
    }
}

add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_status_order' );

View the video (on Youtube)