Use all paid statuses in $customer->get_total_spent()
This commit is contained in:
parent
5605d2cc48
commit
32e814eef1
|
@ -127,7 +127,7 @@ class WC_Report_Customer_List extends WP_List_Table {
|
|||
|
||||
$orders = wc_get_orders( array(
|
||||
'limit' => 1,
|
||||
'status' => array( 'wc-completed', 'wc-processing' ),
|
||||
'status' => array_map( 'wc_get_order_status_name', wc_get_is_paid_statuses() ),
|
||||
'customer' => $user->ID,
|
||||
) );
|
||||
|
||||
|
@ -168,7 +168,7 @@ class WC_Report_Customer_List extends WP_List_Table {
|
|||
|
||||
$orders = wc_get_orders( array(
|
||||
'limit' => 1,
|
||||
'status' => array( 'wc-completed', 'wc-processing' ),
|
||||
'status' => array_map( 'wc_get_order_status_name', wc_get_is_paid_statuses() ),
|
||||
'customer' => array( array( 0, $user->user_email ) ),
|
||||
) );
|
||||
|
||||
|
|
|
@ -285,14 +285,15 @@ class WC_Customer extends WC_Legacy_Customer {
|
|||
if ( '' === $spent ) {
|
||||
global $wpdb;
|
||||
|
||||
$spent = $wpdb->get_var( "SELECT SUM(meta2.meta_value)
|
||||
$statuses = array_map( 'esc_sql', wc_get_is_paid_statuses() );
|
||||
$spent = $wpdb->get_var( "SELECT SUM(meta2.meta_value)
|
||||
FROM $wpdb->posts as posts
|
||||
LEFT JOIN {$wpdb->postmeta} AS meta ON posts.ID = meta.post_id
|
||||
LEFT JOIN {$wpdb->postmeta} AS meta2 ON posts.ID = meta2.post_id
|
||||
WHERE meta.meta_key = '_customer_user'
|
||||
AND meta.meta_value = '" . esc_sql( $this->get_id() ) . "'
|
||||
AND posts.post_type = 'shop_order'
|
||||
AND posts.post_status IN ( 'wc-completed', 'wc-processing' )
|
||||
AND posts.post_status IN ( 'wc-" . implode( "','wc-", $statuses ) . "' )
|
||||
AND meta2.meta_key = '_order_total'
|
||||
" );
|
||||
|
||||
|
|
|
@ -1226,7 +1226,7 @@ class WC_Order extends WC_Abstract_Order {
|
|||
* @return bool
|
||||
*/
|
||||
public function is_paid() {
|
||||
return apply_filters( 'woocommerce_order_is_paid', $this->has_status( apply_filters( 'woocommerce_order_is_paid_statuses', array( 'processing', 'completed' ) ) ), $this );
|
||||
return apply_filters( 'woocommerce_order_is_paid', $this->has_status( wc_get_is_paid_statuses() ), $this );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -96,7 +96,7 @@ class WC_Email_Customer_Invoice extends WC_Email {
|
|||
* @return string
|
||||
*/
|
||||
public function get_subject() {
|
||||
if ( $this->object->has_status( array( 'processing', 'completed' ) ) ) {
|
||||
if ( $this->object->has_status( wc_get_is_paid_statuses() ) ) {
|
||||
return apply_filters( 'woocommerce_email_subject_customer_invoice_paid', $this->format_string( $this->subject_paid ), $this->object );
|
||||
} else {
|
||||
return apply_filters( 'woocommerce_email_subject_customer_invoice', $this->format_string( $this->subject ), $this->object );
|
||||
|
|
|
@ -174,7 +174,7 @@ class WC_Gateway_Paypal_IPN_Handler extends WC_Gateway_Paypal_Response {
|
|||
* @param array $posted
|
||||
*/
|
||||
protected function payment_status_completed( $order, $posted ) {
|
||||
if ( $order->has_status( array( 'processing', 'completed' ) ) ) {
|
||||
if ( $order->has_status( wc_get_is_paid_statuses() ) ) {
|
||||
WC_Gateway_Paypal::log( 'Aborting, Order #' . $order->get_id() . ' is already complete.' );
|
||||
exit;
|
||||
}
|
||||
|
|
|
@ -210,6 +210,15 @@ function wc_is_order_status( $maybe_status ) {
|
|||
return isset( $order_statuses[ $maybe_status ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list of statuses which are consider 'paid'.
|
||||
* @since 2.7.0
|
||||
* @return array
|
||||
*/
|
||||
function wc_get_is_paid_statuses() {
|
||||
return apply_filters( 'woocommerce_order_is_paid_statuses', array( 'processing', 'completed' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Main function for returning orders, uses the WC_Order_Factory class.
|
||||
*
|
||||
|
|
|
@ -220,6 +220,7 @@ function wc_customer_bought_product( $customer_email, $user_id, $product_id ) {
|
|||
}
|
||||
|
||||
$customer_data = array_map( 'esc_sql', array_filter( array_unique( $customer_data ) ) );
|
||||
$statuses = array_map( 'esc_sql', wc_get_is_paid_statuses() );
|
||||
|
||||
if ( sizeof( $customer_data ) == 0 ) {
|
||||
return false;
|
||||
|
@ -230,7 +231,7 @@ function wc_customer_bought_product( $customer_email, $user_id, $product_id ) {
|
|||
INNER JOIN {$wpdb->postmeta} AS pm ON p.ID = pm.post_id
|
||||
INNER JOIN {$wpdb->prefix}woocommerce_order_items AS i ON p.ID = i.order_id
|
||||
INNER JOIN {$wpdb->prefix}woocommerce_order_itemmeta AS im ON i.order_item_id = im.order_item_id
|
||||
WHERE p.post_status IN ( 'wc-completed', 'wc-processing' )
|
||||
WHERE p.post_status IN ( 'wc-" . implode( "','wc-", $statuses ) . "' )
|
||||
AND pm.meta_key IN ( '_billing_email', '_customer_user' )
|
||||
AND im.meta_key IN ( '_product_id', '_variation_id' )
|
||||
AND im.meta_value != 0
|
||||
|
|
|
@ -184,6 +184,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woocommerce/wo
|
|||
* Made wc_get_wildcard_postcodes return the orignal postcode plus * since wildcards should match empty strings too.
|
||||
* New gallery on single product pages with better mobile support, PhotoSwipe and Zoom.
|
||||
* Removed last order from customers part of the API due to performance concerns - use orders endpoint instead. Other order data on the endpoint is now transient cached.
|
||||
* Use all paid statuses in $customer->get_total_spent().
|
||||
|
||||
[See changelog for all versions](https://raw.githubusercontent.com/woocommerce/woocommerce/master/CHANGELOG.txt).
|
||||
|
||||
|
|
Loading…
Reference in New Issue