Saltar navegación

[Cerrado] change custom field when order expires

This support ticket is created hace 7 meses. There's a good chance that you are reading advice that it now obsolete.

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.

Este tema contiene 1 respuesta, tiene 2 mensajes.

Última actualización por Christopher Amirian hace 7 meses.

Asistido por: Christopher Amirian.

Autor
Mensajes
#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
Colaborador

Idiomas: Inglés (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.

El debate ‘[Cerrado] change custom field when order expires’ está cerrado y no admite más respuestas.