Reputation: 2586
I can see inside class-wc-admin-cpt-shop_order.php
there are some functions that are pulling together the order information for display in WooCommerce. However, I don't see anywhere where the date can be used ...
Because WooCommerce uses wp_posts
to store the data, can I assume that the post_date field
is the correct one to use?
Also, anyone know whether there is a function in WooCommerce to get this, or whether there is a way of getting the date to come out in class-wc-admin-cpt-shop_order.php
.
Upvotes: 20
Views: 64913
Reputation: 4212
// Get $order object from order ID
$order = wc_get_order( $order_id );
// Get Order Dates
$order->get_date_created();
$order->get_date_modified();
$order->get_date_completed();
$order->get_date_paid();
Source: https://businessbloomer.com/woocommerce-easily-get-order-info-total-items-etc-from-order-object/
Additionally
$order->get_date_created();
Is the "order date", which you can change within WooCommerce ("Edit Order")
Upvotes: 31
Reputation: 1499
Order properties should not be accessed directly. Best way is $order->get_date_completed()
Upvotes: 9