php - 如何在 WooCommerce 中获取所有订单状态的 slug 和名称?

标签 php wordpress function woocommerce orders

我想获取所有 WooCommerce 订单状态的所有 slug 和名称。 我尝试了以下线程的答案:Woocommerce get list of order statuses list但没有成功。

我使用最新的 woocommerce 版本。感谢您的帮助。

最佳答案

您将使用专用函数 wc_get_order_statuses() ,来自 WC_Order 函数,它默认为您提供以下数组:

$order_statuses = array(
    'wc-pending'    => _x( 'Pending payment', 'Order status', 'woocommerce' ),
    'wc-processing' => _x( 'Processing', 'Order status', 'woocommerce' ),
    'wc-on-hold'    => _x( 'On hold', 'Order status', 'woocommerce' ),
    'wc-completed'  => _x( 'Completed', 'Order status', 'woocommerce' ),
    'wc-cancelled'  => _x( 'Cancelled', 'Order status', 'woocommerce' ),
    'wc-refunded'   => _x( 'Refunded', 'Order status', 'woocommerce' ),
    'wc-failed'     => _x( 'Failed', 'Order status', 'woocommerce' ),
);

All custom additional order statuses will be included too as the filter hook wc_order_statuses is applied inside this function.

关于php - 如何在 WooCommerce 中获取所有订单状态的 slug 和名称?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59863954/

相关文章:

php - 将mysql数据库中的数据打印到php中

java - 在Azure Function Java中,如何使用HttpResponseMessage设置cookie

css - 接触 7 形式延伸到所需宽度之外

c - 我是否正确实现了 Square 函数?

python - 无法让我的计数函数在 Python 中运行

javascript - 使用 jquery 向同一页面发送 GET 请求

php - 你能在本地服务器上做 RSS 提要吗? (PHP)

PHP - 为什么当前日期与数据库内的日期不同?

wordpress - 动态 WordPress 自定义元框

php - 对于这样的搜索查询,我可以使用什么 Wordpress 函数?