升级Wordpress 5.0.3后Woocommerce订单未全部显示

时间:2019-02-14 17:21:31

标签: php wordpress woocommerce

将WordPress升级到v5.0.3之后,Woocommerce订单未在管理面板的订单页面中全部显示。 稍作调试后,两个版本之间发送的查询有所不同。 曾经是:

SELECT SQL_CALC_FOUND_ROWS  wp_posts.ID FROM wp_posts  WHERE 1=1  AND wp_posts.post_type = 'shop_order' AND ((wp_posts.post_status = 'wc-pending' OR wp_posts.post_status = 'wc-processing' OR wp_posts.post_status = 'wc-on-hold' OR wp_posts.post_status = 'wc-completed' OR wp_posts.post_status = 'wc-cancelled' OR wp_posts.post_status = 'wc-refunded' OR wp_posts.post_status = 'wc-failed' OR wp_posts.post_status = 'wc-shipped' OR wp_posts.post_status = 'wc-approved'))  ORDER BY wp_posts.post_date DESC LIMIT 0, 20

之前但在较新版本中为:

SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts WHERE 1=1 AND wp_posts.post_type = 'shop_order' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'wc-shipped' OR wp_posts.post_status = 'wc-approved' OR wp_posts.post_status = 'future' OR wp_posts.post_status = 'draft' OR wp_posts.post_status = 'pending' OR wp_posts.post_status = 'private') ORDER BY wp_posts.post_date DESC LIMIT 0, 20

我正在使用WooCommerce v3.2.1

1 个答案:

答案 0 :(得分:1)

问题是新查询缺少订单的某些状态。

由于无法更新WooCommerce,因此可以进入核心文件并执行与修订中相同的更改。

includes/admin/list-tables/class-wc-admin-list-table-orders.php中查找:

if ( ! isset( $query_vars['post_status'] ) ) {

并将其更改为:

if ( empty( $query_vars['post_status'] ) ) {

因为WordPress的默认变量已更改。

这是有问题的提交:https://github.com/woocommerce/woocommerce/compare/3.5.2...3.5.3#diff-572cadf09364d3a4d4e8c20e061b21f5

发布说明在这里:https://woocommerce.wordpress.com/2018/12/20/woocommerce-3-5-3-release-notes/

更新

由于文件3.5.2中不存在,因此可以在class-wc-admin-post-types.php的{​​{1}}中执行相同的更改:

line 1635

收件人:

if ( ! isset( $vars['post_status'] ) ) {