How can I get, on Woocommerce, the date an order had its status changed to paid/complete?
I saw something about getting the orders from a costumer, but this would be just the first step of my algorithm. Then I would need to know when it changed to complete.
The idea is to make a membership area: a payment lasts 3 months. So I will count the days passed since it was bought
Something related https://www.skyverge.com/blog/get-all-woocommerce-orders-for-a-customer/
And this is what I use to know if a product was bought by the costumer
if (wc_customer_bought_product($customer_email, $user_id,$loop->post->ID)){
$courses[] = $this->find($loop->post->ID);
}
I think you should look into:
/mySite/wp-content/plugins/woocommerce/includes/abstracts/abstract-wc-order.php
There is a __get function:
public function __get( $key ) {
// Get values or default if not set.
if ( 'completed_date' === $key ) {
$value = ( $value = get_post_meta( $this->id, '_completed_date', true ) ) ? $value : $this->modified_date;
} elseif ( 'user_id' === $key ) {
$value = ( $value = get_post_meta( $this->id, '_customer_user', true ) ) ? absint( $value ) : '';
} elseif ( 'status' === $key ) {
$value = $this->get_status();
} else {
$value = get_post_meta( $this->id, '_' . $key, true );
}
return $value;
}
So my understanding is that if you pass 'completed date' as the argument then it will return the completed_date.
It also gives you a hint where this date is i.e.
get_post_meta
Well, at least that's where I would start.