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
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.