Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #985733

    Hello,

    You know, when you order via WooCommerce, two mails are being send out.
    1. For the customer who purchased something via WooCommerce. He is getting something like a receipt.
    2. The owner of the website who is selling stuff via WooCommerce. He is getting a purchase order.

    On my website I have a few reservation request forms. These forms have been build with Enfolds Contact Form.
    After someone fills in the form, I want Enfold Contact Form to send two mails.

    1. For the customer who has made a reservation request via Enfold Contact Form.
    2. Me, so I can hande the request accordingly.

    These mails should be somewhat identical. Because, the customer who has made a reservation request, needs to receive an email with all the details he has filled in within the form on my website.

    Hwo can I achieve this?

    #985746

    Hey Jillian,

    Please add this code to your child theme functions.php:

    
    add_filter('avf_form_custom_autoresponder', 'avia_custom_autoresponder', 10, 4);
    function avia_custom_autoresponder($autoresponder, $message, $class, $new_post)
    {
    	$message = "
    
    <strong>" . __('Your Request:','avia_framework') . " </strong>
    
    ";
    
    	foreach($class->form_elements as $key => $element)
    	{
    		if(isset($element['id'])) $key = $element['id'];
    
    		$key = avia_backend_safe_string($key, '_', true);
    
    		if(empty($key) || !empty($class->form_params['numeric_names']) )
    		{
    			$iterations++;
    			$key = $iterations;
    		}
    
    		// substract 5 characters from the string length because we removed the avia_ prefix with 5 characters at the beginning of the send() function 
    		$key = avia_backend_truncate($key, $class->length - 5, "_", "", false, '', false);
    
    		$key .= $class->id_sufix;
    
    		if(!empty($new_post[$key]))
    		{
    			if($element['type'] != 'hidden' && $element['type'] != 'decoy')
    			{
    				if($element['type'] == 'textarea') $message .= "
    ";
    				$field_value = apply_filters( "avf_form_mail_field_values", nl2br(urldecode($new_post[$key])), $new_post, $class->form_elements, $class->form_params, $element, $key );
    				$message .= $element['label'].": ".$field_value."
    ";
    				if($element['type'] == 'textarea') $message .= "
    ";
    			}
    		}
    	}
    
    	$message .= 'FINAL TEXT';
    
    	$autoresponder = $message;
    
    	return $autoresponder;
    }
    

    You can replace the text strings “Your Request:” and “FINAL TEXT” with some custom text.

    Best regards,
    Dude

    #985760

    Hi,

    I don’t have child theme installed. What can I do in this situation?

    #986499

    Hi,

    You can add it to enfold/functions.php – just place it at the end of the file.

    Best regards,
    Dude

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Send filled in contact form via E-mail’ is closed to new replies.