Actually, this won’t work. Reason being, you need access to the order to get the date for comparison!
So you have options:
1) When you run the date difference checker the first time (as per your other post), I think I’d be inclined to have another custom field which stores the value from:
$date_created = $order->get_date_created();
2) When you run the date difference code for the first time (as per your other post), you store if post ID of the order. That way, you can query the order post ID to get the order completed date.
In my mind, option 1 is far easier and easier to implement:
1) Just an another update_meta line to your other code
2) Add a get_field on the code I posted above to get the order completed date
As I say, my only concern is how many posts you may need to return each day, may timeout or become slow
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
© 2023 Advanced Custom Fields.