I have searched all over the internet. What I'm looking for is to create a custom woocommerce order field which will be automatically added to the order when order status changes to wc-kurzuhradena which the custom order status, with the value of current month and year. Example value: May 2021
So far I have this code which adds a custom field but I need to find a solution for a date when this status has been updated.
function add_date_field_shipped() {
global $woocommerce, $post;
$order = new WC_Order($post->ID);
if ( empty(get_post_meta( $post->ID, 'shipped', true)) && ('kurzuhrada' == $order->status)) {
update_post_meta( $post->ID, 'shipped', 'value here',true);
}
}
add_action( 'pre_get_posts', 'add_date_field_shipped' );
Thank you in advance for help.
