wordpress 如何在 WooCommerce 中获取订单日期?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31746767/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I get the order date, in WooCommerce?
提问by Ke.
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 ...
我可以看到里面class-wc-admin-cpt-shop_order.php
有一些功能将订单信息汇总在一起以在 WooCommerce 中显示。但是,我没有看到可以使用日期的任何地方......
Because WooCommerce uses wp_posts
to store the data, can I assume that the post_date field
is the correct one to use?
因为 WooCommerce 用于wp_posts
存储数据,所以我可以假设使用的post_date field
是正确的吗?
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
.
此外,任何人都知道 WooCommerce 中是否有一个功能可以得到这个,或者是否有办法让日期出现在class-wc-admin-cpt-shop_order.php
.
回答by rnevius
回答by user5510975
Order properties should not be accessed directly. Best way is $order->get_date_completed()
不应直接访问订单属性。最好的办法是$order->get_date_completed()
回答by optimiertes
// 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/
资料来源: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")
是“订单日期”,您可以在 WooCommerce 中更改(“编辑订单”)