Hello Carlos.
To my understanding, you have a "New Products" CRED form, that among other fields, it also has a select field for the "Status" and a datepicker field for the Cancellation Date.
So, upon form submission, you want to check if the user submitted a cancellation date and if he did, then you want that product to expire at that date.
In order to achieve this, you need the following code
add_action('cred_save_data', 'check_if_cancellation_date_is_present',10,2);
function check_if_cancellation_date_is_present($post_id, $form_data)
{
// if a specific form
if ($form_data['id']==354)
{
if (isset($_POST['wpcf-cancellation-date']))
{
update_post_meta($post_id, '_cred_post_expiration_time', $_POST['wpcf-cancellation-date']['datepicker']);
}
}
}
add_filter('cred_post_expiration_custom_actions', 'actions_for_cancellation', 10, 3);
function actions_for_cancellation($custom_actions, $post_id, $form_data) {
$custom_actions[] = array( 'meta_key' => 'wpcf-status', 'meta_value' => '3' );
return $custom_actions;
}
The first function checks the submission of a specific form (you need to change '354' to the id of your form) and if the submitted form is the form you want and the cancellation date is submitted, then the product is set to expire on the select date. Keep in mind that if you select the 21st of October 2016, the product will expire at 00:00:00 21st of October 2016.
The second function performs custom actions when a post expires, so in your case, the function, upon product expiration, will update the "Status" field of that post to 3, which is the value for "Cancelled".
You might need to adjust this code a little bit to suit your needs, but I hope you get the general idea of the proposed solution.
If this doesn't resolve your issue or you have any further issues or questions, please let me know.
Regards