• Resolved KeithC2O

    (@keithbernardce)


    Is it possible to calculate totals from form fields (eg {event-cost} * {other} when using {other} as the number of tickets?

    so can have total-event-cost in email sent to User?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author roundupwp

    (@roundupwp)

    Hey KeithC20,

    Yep this is possible! This article explains the needed PHP hook. I created something that might work for you. You can use something like WPCode to add activate it for your site:

    function ru_add_event_cost_template( $search_replace, $sanitized_data ) {
    $event_id = isset( $sanitized_data['event_id'] ) ? $sanitized_data['event_id'] : false;

    if ( function_exists( 'tribe_get_cost' ) && false !== $event_id ) {
    $event_cost = tribe_get_cost( $event_id, false );
    if ( ! empty( $sanitized_data['other'] ) ) {
    $search_replace['{event-cost}'] = (float)$event_cost * (int)$sanitized_data['other'];
    } else {
    $search_replace['{event-cost}'] = $event_cost;
    }
    }

    return $search_replace;
    }
    add_filter( 'rtec_email_templating', 'ru_add_event_cost_template', 10, 2 );

    Let me know if you need more help!

    – Craig

    Thread Starter KeithC2O

    (@keithbernardce)

    Hi Craig

    That worked great.

    I just had to add a new {total-event-cost] field to the email and add a calculated field in the code.
    (Just so I could display original and total values).

    Thanks for the quick solution.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.