Which order statuses cause an order to be allocated a slot?

If you have limited the number of orders that can be placed within a specific time slot, then it is important to note that not all order statuses cause the order to count. By default, a cancelled or trashed order does not count.

However, you may have reasons for having other order statuses not count either – for example, you have created new order statuses, or your payment gateway creates orders before payment in a state (e.g. pending payment) which you do not wish to count (until the order is paid).

To accomplish this, you can use the openinghours_order_uses_slot filter. To do this:

  1. Create the folder wp-content/mu-plugins (if it does not already exist in your WordPress install).
  2. In it, create a file ending in .php, for example wp-content/mu-plugins/openinghours-changes.php .
  3. In that file, add content like so:

    add_filter('openinghours_order_uses_slot', function($uses_slot, $order_id) {
    $order = wc_get_order($order_id);
    $order_status = $order->get_status();
    if ('pending' == $order_status) $uses_slot = false;
    return $uses_slot;
    }, 10, 2);

In the above example, pending is the internal ID used by WooCommerce. It may not necessarily be the same as the text shown in the user interface.Please note that plugin coding customisations are not part of our standard support service. We can provide quotes for bespoke work, or you can hire a developer from various available sources, such as Codeable.

Posted in: WooCommerce Opening Hours and Delivery Times