Skip Navigation

[Closed] change custom field when order expires

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 1 reply, has 2 voices.

Last updated by Christopher Amirian 2 months, 1 week ago.

Assisted by: Christopher Amirian.

Author
Posts
#2777420

Hi there

I am using this little snippet on several other sites and it works very well but it doesn't seem to be working on this site. When a woocommerce shop order expires the snippet should change the order's custom select field from '1' to '2'.

In functions.php I have this:

add_filter('cred_post_expiration_custom_actions', 'set_expiration_order', 10, 3);
function set_expiration_order ($custom_actions, $post_id, $form_data) {
$postType = get_post_type( $post_id );
if ( $postType == 'shop_order' ) {
$custom_actions[] = array( 'meta_key' => 'wpcf-order-send-email-trigger', 'meta_value' =>'2' );
}
return $custom_actions;
}

It feels like the site does not recognise 'shop_order' as a post type...

Thanks in advance!

Rita

#2777525

Christopher Amirian
Supporter

Languages: English (English )

Hi Rita,

Delving into a custom code is outside of our support scope and we can not debug the code you have.

I can give some general suggestions:

Try to add something like:

error_log('Post type: ' . $postType);

To see if shop_order is really what it is showing or not. Maybe Woocommerce changes that or for some reason your installation returns another value.

That way you will know if you target the order post type correctly in the first place.

The other point is that the "cred_post_expiration_custom_actions" is fired only if you activate the "Expiration date:" setting in the form.

For more information:

https://toolset.com/forums/topic/cred_post_expiration_custom_actions-issue/

https://toolset.com/course-lesson/setting-up-automatic-post-expiration/

Thanks.

The topic ‘[Closed] change custom field when order expires’ is closed to new replies.