Fix recent sales query, restrict to completed orders

This commit is contained in:
Eric Jinks 2022-05-04 16:52:46 +10:00
parent bfa9721dda
commit f9fd51e81c
No known key found for this signature in database
GPG Key ID: 22C09ACBC4DC9279
1 changed files with 7 additions and 2 deletions

View File

@ -104,7 +104,7 @@ class WcPaySubscriptionsPage {
// Ineligible if store has not had any sales in the last 30 days.
$store_recent_sales_count = $this->get_store_recent_sales_count();
if ( ! $store_recent_sales_count || $store_recent_sales_count < 1 ) {
if ( $store_recent_sales_count < 1 ) {
return false;
}
@ -116,7 +116,12 @@ class WcPaySubscriptionsPage {
*/
private function get_store_recent_sales_count() {
// Get orders that were paid in the last 30 days.
$orders = wc_get_orders( array( 'date_paid' => '>' . strtotime( '-30 days' ) ) );
$orders = wc_get_orders(
array(
'date_paid' => '>' . strtotime( '-30 days' ),
'status' => array( 'wc-completed' ),
)
);
return count( $orders );
}