Note:
This is a developer-level doc. If you are unfamiliar working with code and resolving potential conflicts, we recommend you work with a Woo Agency Partner for larger projects, or find a WooCommerce developer on Codeable for smaller customization work. We are unable to provide support for customization under our Support Policy.
Use a custom AutomateWoo rule when a workflow needs to compare a value your integration stores. This example adds an Order – Delivery date rule that reads the delivery_date order meta field and uses AutomateWoo’s date comparisons.
Before you start, activate WooCommerce and AutomateWoo on a staging site. This example assumes your integration supplies the delivery_date field.
Register the rule
↑ Back to topUnder wp-content/plugins, create a folder named my-store-automatewoo-rules. In that folder, create my-store-automatewoo-rules.php with the following code.
<?php
/**
* Plugin Name: My Store AutomateWoo Rules
* Description: Adds a delivery-date rule for order workflows.
*/
defined( 'ABSPATH' ) || exit;
add_action(
'plugins_loaded',
function() {
if ( ! class_exists( '\AutomateWoo\Rules\Abstract_Date' ) ) {
return;
}
require_once __DIR__ . '/includes/class-order-delivery-date-rule.php';
add_filter(
'automatewoo/rules/includes',
function( $rules ) {
$rules['my_store_order_delivery_date'] = My_Store_AutomateWoo_Order_Delivery_Date_Rule::class;
return $rules;
}
);
}
);
Use a unique array key. AutomateWoo saves that key with each workflow that uses the rule, so keep the key stable after you start using it.
Define the delivery-date rule
↑ Back to topIn the plugin folder, create an includes folder and save the following code in includes/class-order-delivery-date-rule.php.
<?php
defined( 'ABSPATH' ) || exit;
class My_Store_AutomateWoo_Order_Delivery_Date_Rule extends \AutomateWoo\Rules\Abstract_Date {
public $data_item = 'order';
public function __construct() {
$this->has_is_past_comparision = true;
parent::__construct();
}
public function init() {
$this->title = __( 'Order - Delivery date', 'my-store-automatewoo-rules' );
}
public function validate( $order, $compare, $value = null ) {
$delivery_date = aw_normalize_date( $order->get_meta( 'delivery_date' ) );
return $this->validate_date( $compare, $value, $delivery_date );
}
}
The order data item makes the rule available to workflows with order data. The has_is_past_comparision property enables past-date comparisons. The example uses a date string in YYYY-MM-DD format. If your integration uses another key or stores a timestamp, adjust the meta lookup and confirm that you pass the intended date and time zone to the date comparison.
Test the rule
↑ Back to top- Activate My Store AutomateWoo Rules on your staging site.
- In AutomateWoo > Workflows, open an automatic workflow with an order trigger. For this example, select Order Created and leave the workflow disabled while you configure it.
- Under Rules, select Add Rule Group. Choose Order – Delivery date, then Is in the last, 7, and Calendar days. Save the workflow and check that the rule and comparison are still selected.

If the rule doesn’t appear, check that the custom plugin is active and the workflow’s trigger supplies order data.
To test the full workflow on staging, choose an order trigger that runs after your integration writes the delivery date. Use a private order note as the action and run the workflow against test orders. Check that it adds a note for an order dated yesterday and skips orders with a date outside the seven-day window or with the field unset.