• Resolved kaizerco

    (@kaizerco)


    I’m thinking to use happyforms as an order form. For it to be a viable solution, I would need to be able to send to the sender a copy or a processed copy of the order form. Currently the sender has no copy or confirmation of the exact information that was sent (i.e. the order). What’s an order without proof you ordered it.

    Do you have plans to be able to use shortcode fields like [from.name] [from.email] [to.name] etc. in the confirmation email? ??

    Do you have plans to process payments one day? Hookup to paypal, etc?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hey there, @kaizerco!

    Definitely! It’s one of the most requested features, and we have big plans for this. In particular, rich email formatting with placeholders, and a better set of filters for advanced usage.

    Payments too are a subject we’re looking into – although different payment gateways have very different and specific mechanics, and it will take time to identify the right approach.

    If you’re interested in code-based solutions (in particular, for the first point in your question), I’d be happy to share some examples based on HappyForms actions and filters.

    Let us know what you think!

    Thread Starter kaizerco

    (@kaizerco)

    Hi,
    Sure, I’m interested in code-based solutions (for sending a copy of the order form?)

    Hey again, @kaizerco!

    If you plan to send your users a copy of their submission data, you won’t really need a shortcode. I’m sharing an example below, that simply replicates what happens with owner submission alerts. The outcome of this is that your users will receive a full copy of their submission:

    function child_theme_happyforms_email_content( $content, $message, $to ) {
        $form = happyforms_get_form_controller()->get( $message['form_id'] );
    
        // Check if this is being sent to the site owner.
        // If it is, return early because this isn't 
        // the email message we want to tweak.
        if ( '[email protected]' === $to ) {
            return $content;
        }
    
        $content_lines = array();
    
        foreach ( $form['parts'] as $part_data ) {
            $part_id = $part_data['id'];
            $label = happyforms_get_email_part_label( $message, $part_data, $form );
            $value = happyforms_get_email_part_value( $message, $part_data, $form );
            $content_lines[] = "<b>{$label}</b><br>{$value}";
        }
    
        $content = implode( '<br><br>', $content_lines );
    
        return $content;
    }
    
    add_filter( 'happyforms_email_content', 'child_theme_happyforms_email_content', 10, 3 );

    I’d like to clarify some details:

    1. HappyForms doesn’t support placeholders for rendering your submission data (like [first_name]). That’s going to land at some point, but it’s not available yet.
    2. If you want to render your own shortcodes inside your content, just add them in your Email content setting, and add a…

    $content = do_shortcode( $content );

    …before returning your content value.

    I hope that does the trick! Let us know how that goes. ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Shortcodes in confirmation email?’ is closed to new replies.