woocommerce/woocommerce

Regenerating product tables does not account for deleted orders

Closed

#27,359 opened on Aug 17, 2020

 (1 comment) (0 reactions) (0 assignees)PHP (10,695 forks)batch import
BugData Structure/CRUD/Backend ProcessingFluxGood First IssueProduct/Inventory Managementplugin: woocommerce

Repository metrics

Stars
 (10,294 stars)
PR merge metrics
 (Avg merge 9d 12h) (423 merged PRs in 30d)

Description

Prerequisites (mark completed items with an [x]):

  • I have carried out troubleshooting steps and I believe I have found a bug.
  • I have searched for similar bugs in both open and closed issues and cannot find a duplicate.

Describe the bug The issue started when looking for differences between the best seller shortcode ( [products limit="3" columns="3" best_selling="true" ] ) and the Best Selling Products block. After permently deleting orders the total_sales within wc_product_meta_lookup and wp_postmeta.

Expected behavior When orders are deleted, both total_sales values be updated to that shortcode and block product tools show the correct information.

Steps to reproduce the bug (We need to be able to reproduce the bug in order to fix it.) Steps to reproduce the bug:

  1. Review total_sales for a specific post id within wc_product_meta_lookup and wp_postmeta
  2. Permanently delete all orders specific to that product
  3. Regenerate product lookup tables ( wc > status > tools )
  4. See total sales meta values unchanged

Isolating the problem (mark completed items with an [x]):

  • I have deactivated other plugins and confirmed this bug occurs when only WooCommerce plugin is active.
  • This bug happens with a default WordPress theme active, or Storefront.
  • I can reproduce this bug consistently using the steps above.

Contributor guide