Black Friday & Cyber Monday SUPER SALE ALL WEEK:
Grab 40% OFF on plugins
Days
Hours
Minutes
Seconds

How to Add Order Creation Timestamp to the WooCommerce Order Number?

Timestamps are required for store owners to prioritize the orders based on the time they were placed. And placing the timestamp right on the orders table helps them to quickly identify which order needs to be processed first. This easy-to-follow guide will help you to incorporate timestamp into the orders table.

Solution: Add Order Creation Timestamp to the WooCommerce Order Number

By using WordPress functions like current_time(), the code will retrieve the site’s local time and display it alongside the order numbers.

add_filter( 'woocommerce_order_number', 'ts_change_woocommerce_order_number', 1, 2 );

function ts_change_woocommerce_order_number( $order_id, $order ) {
    // Get the current date and time
    $current_time = current_time( 'Y-m-d H:i:s' );

    // Concatenate the current date and time with the order ID
    $new_order_id = $current_time . '-' . $order_id;

    return $new_order_id;
}

Output

The output represents the modified order number that includes both the current date and time when the order was created, along with the original order ID. For example, an output of 2024-05-15 14:30:45 – 1234 indicates that the order with ID 1234 was created on May 15, 2024, at 2:30:45 PM local time.

How to Add Order Creation Timestamp to the WooCommerce Order Number? - Tyche Softwares

Interested in adding date as a prefix to your WooCommerce order numbers? You can easily achieve this with a simple code snippet. If you require further customizations, feel free to let us know in the comments.

Browse more in: Code Snippets, WooCommerce How Tos, WooCommerce Tutorials

Share It:

Subscribe
Notify of
0 Comments
Newest
Oldest
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x