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
- Got to Orderable->Order Statuses->Add New
- Enter ‘Pre-order’ as title
- Tick enabled
- Status Type as Custom
- Slug, should already fill-out to be ‘pre-order’
- Choose your preferred Colour and Icon
- Hit Publish
- Add the second status with the title of ‘Preparing’
- Tick enabled
- Status Type as Processing
- Slug, should already fill-out to be ‘processing’
- Choose your preferred Colour and Icon
- 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' );