Get the date an order was paid on Woocommerce

Viewed 5059

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);
          }
3 Answers

Probably the "most correct" way is:

$order = new WC_Order($order_id);
$date_obj = $order->get_date_paid();
echo $date_obj->date('d/m/Y'); 

This should to the job on recente WP/WooCommerce.

$order = new WC_Order($sale_id);
echo $order->get_date_paid();
Related