Last active
June 28, 2019 02:30
-
-
Save 75nineteen/883d392e508a7745ab6c to your computer and use it in GitHub Desktop.
Another example for building your own custom variables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'fue_before_variable_replacements', 'fue_register_variable_replacements', 10, 4); | |
function fue_register_variable_replacements( $var, $email_data, $fue_email, $queue_item ) { | |
$variables = array( | |
'referral_code' => '' | |
); | |
if ( isset( $email_data['test'] ) && $email_data['test'] ) { | |
$variables['referral_code'] = '13221'; | |
if ( !empty( $email_data['order_id'] ) ) { | |
$order = wc_get_order( $email_data['order_id'] ); | |
$referral_code = get_user_meta( $order->customer_user, '_affiliate_key', true ); | |
if ( !empty( $referral_code ) ) { | |
$variables['referral_code'] = $referral_code; | |
} | |
} | |
} else { | |
if ( !empty( $queue_item->order_id ) ) { | |
$order = wc_get_order( $queue_item->order_id ); | |
$referral_code = get_user_meta( $order->customer_user, '_affiliate_key', true ); | |
if ( !empty( $referral_code ) ) { | |
$variables['referral_code'] = $referral_code; | |
} | |
} | |
} | |
$var->register( $variables ); | |
} |
not working for me either. When I add the code and test it on the site it gives me the test data in a preview, but is totally blank on email
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm having the same problem as dacgarz. Is there an update on this issue? I'm not able to add a custom variable now.