Custom Woocommerce Field in Follow Up Addon

Moring all.

I am not an expert in php by any means but have given this hours of reading and testing to no avail.

I am using the WooCommerce Checkout Manager plugin to create custom fields. This works and the data is successfully stored as meta in the order. Great.

However, I use the Woocommerce Follow Up plugin for delivery of emails as have various products and wish for the emails to be different for each. The problem being that I cannot map the custom checkout fields to be referenced in my emails.

I have read the Woocommerce documetation to this (https://docs.woocommerce.com/document/automated-follow-up-emails-docs/custom-variables/) but cannot transpose to my situation. I have also tried writing the php from scratch but again this does not work. In both instances the email delivery with no field populated.

My custom field have the meta of ‘billing_myfield20’ and the label is ‘Membership Start Date’.

Any assistance would be greatly appreciated.

G

My code:

add_action( 'fue_before_variable_replacements', 'fue_register_variable_replacements', 10, 4);

function fue_register_variable_replacements( $var, $fue_email, $queue_item ) { 
    $variables = array(
        'Membership Start Date' => ''
    );

        $order = wc_get_order( $order_id );

        $start_date = get_user_meta($order, 'billing_myfield20', true);

        $variables['Membership Start Date'] = $start_date;

    $var->register( $variables );
}

Read more here: Custom Woocommerce Field in Follow Up Addon

Leave a Reply

Your email address will not be published. Required fields are marked *