Last active
August 2, 2018 10:01
-
-
Save bernattorras/a16d4e09112ddfdf507d43e5f20a3c50 to your computer and use it in GitHub Desktop.
Function to get all the renewal orders with a specific status of a customer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function wc_get_customer_renewal_orders_by_status($customer_id, $status) { | |
$args = array( | |
'post_type' => 'shop_order', | |
'post_status' => $status, | |
'order' => 'ASC', | |
'meta_query' => array( | |
array( | |
'key' => '_customer_user', | |
'value' => $customer_id, | |
'compare' => '=', | |
), | |
array( | |
'key' => '_subscription_renewal', | |
'value' => '', | |
'compare' => '!=', | |
), | |
), | |
); | |
$query = new WP_Query( $args ); | |
if ( $query->have_posts() ) { | |
return $query->posts; | |
} | |
return false; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment