Hi,
Thanks for the clever solution.
However, there's now a bug with the confirmation email - the data from the form is not coming across in the confirmation email now.
I'm a bit worried because it is now live.
UPDATE:
I deactivated the custom code and the confirmation email data came across.
I'm just looking at what could be causing these fields to not come across in the confirmation email.
example:
Name: [types field='fname' item='%%POST_ID%%'][/types] [types field='lname' item='%%POST_ID%%'][/types]
used to show the fields, now it just shows
Name:
UPDATE 2:
There is additional code beyond what you have included in your reply.
Should all this still be there?
Also, is it possible to write the order number when the order status is 'On Hold' - This helps us to follow up on people who haven't yet paid.
// Put the code of your snippet below this comment.
add_action( 'cred_commerce_after_order_completed', 'save_order_num', 10, 1 );
function save_order_num( $data ) {
//some code here
$forms = array( 49, 407 );
if( in_array( $data['extra_data'][0]['cred_form_id'], $forms ) ){
$order_num = $data['transaction_id'];
update_post_meta($data['extra_data'][0]['cred_post_id'],'wpcf-woo-order-number', $order_num );
}
}
add_action( 'cred_commerce_after_order_completed', 'my_cred_commerce_after_order_completed', 10, 1 );
function my_cred_commerce_after_order_completed( $data ) {
error_log('my_cred_commerce_after_order_completed');
error_log( print_r( $data, true ) );
}
add_filter('cred_subject_notification_codes', 'my_field_notification', 999, 3);
add_filter('cred_body_notification_codes', 'my_field_notification', 999, 3);
function my_field_notification( $defaultPlaceHolders, $form_id,$post_id ) {
if( $form_id == 407 ) {
// form data
$form_data = get_post($form_id,ARRAY_A);
// post data
$post_data = get_post($post_id,ARRAY_A);
$newPlaceHolders['%%MY_FORM_DATA%%'] = '<pre>MY_FORM_DATA: ' . print_r( $form_data, true ) . '</pre>';
$newPlaceHolders['%%MY_POST_DATA%%'] = '<pre>MY_POST_DATA: ' . print_r( $post_data, true ) . '</pre>';
error_log('my_cred_notification_codes');
error_log( print_r( array(
'form_id' => $form_id,
'post_id' => $post_id,
'form_data' => $form_data,
'post_data' => $post_data,
), true ) );
return array_merge($defaultPlaceHolders, $newPlaceHolders );
}
}