Viewing 14 replies - 1 through 14 (of 14 total)
  • We add quite a few more then what WooCommerce core includes. And I’m happy to take any requests. You can also add your own function to include your own custom placeholders.

    customer_email has not been requested before. I’d be happy to consider it.

    Can you give me context for how you want to use it and in which email templates?

    Ben

    Thread Starter rambo3000

    (@rambo3000)

    In my system customer’s usernames are their emails (Woocommerce doesn’t support this by default, so I have to use other plugins to mitigate this).

    How would you recommend to add a function to include user email placeholder?

    p.s. amazing support ??

    There is a {customer_username} placeholder.

    If you’ve set that to be the email then it would output the email.

    Otherwise, which email templates are you wanting to use this in. It’s a little different approach depending on the template.

    Thread Starter rambo3000

    (@rambo3000)

    I’m editing new customer account template.

    Basically, usernames in my system are not used for logging in, I’m using another plugin, which uses emails instead of username to login. This is because Woocommerce doesn’t allow emails to be used as usernames.

    So if I want to provide username to my user (which is his email), then I must use user_email placeholder instead of his real username.

    You’ve mentioned that I can write a placeholder function of my own, would happily do this if you direct me to the right place.

    For the new account email you can use a function like this:

    add_filter( 'kadence_woomail_no_order_body_text', 'custom_function_for_user_email', 10, 2 );
    function custom_function_for_user_email( $text, $email ) {
    if ( is_a( $email->object, 'WP_User' ) ) {
    $text = str_replace( '{customer_email}',  $email->object->user_email, $text );
    }
    return $text;
    }
    Thread Starter rambo3000

    (@rambo3000)

    That worked perfectly.

    Ben, you’re a star ??

    You bet!

    Ben

    Hi,

    I’m refreshing the topic because the initial question is exactly what I’m trying to do (i.e. add other placeholders, more specifically the order billing email). Based on the posts above, I’m not sure to know where this code/function should be added to?

    Thank you for the help and this awesome plugin.

    add_filter( 'kadence_woomail_order_body_text', 'custom_function_for_billing_email', 10, 2 );
    function custom_function_for_billing_email( $text, $order ) {
    if ( is_a( $order, 'WC_Order' ) ) {
    $text = str_replace( '{billing_email}',  $order->get_billing_email(), $text );
    }
    return $text;
    }

    It could look like the above code.

    Ben

    Hi Ben,

    Thanks for your feedback. My question was more about where to add this code? I’m a true beginner with WP and I’m just not sure to know where this piece of code should be added (which file to be modified)?

    Thanks again

    hannah

    (@hannahritner)

    Hi @neoseo1300,
    You can paste that into the functions.php of your child theme. You can read about child themes here if you’re unfamiliar: https://www.kadencewp.com/child-themes/
    Hope that helps!

    Hannah

    Hi Hannah,

    Thanks for your answer. I’ve created a child theme which works perfectly (i.e. it mirrors the parent theme) but when I add your code in the functions.php of the child theme, it doesn’t seem to add the placeholder, instead, the code appears as text at the top of every page of the website.

    It seems like wordpress doesn’t interpret it as a function but simply as text. What did I miss?

    My functions.php in the child theme looks like that:

    <?php
    add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' );
    
    function enqueue_parent_styles() {
       wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
    }
    ?>
    
    add_filter( 'kadence_woomail_order_body_text', 'custom_function_for_billing_email', 10, 2 );
    function custom_function_for_billing_email( $text, $order ) {
    if ( is_a( $order, 'WC_Order' ) ) {
    $text = str_replace( '{billing_email}',  $order->get_billing_email(), $text );
    }
    return $text;
    }

    Thanks again!

    Edit: I think I identified the mistake, I should put the code before the ?> of the PHP function.

    Edit 2: indeed, that was the mistake, it works now! thanks again

    • This reply was modified 5 years, 1 month ago by neoseo1300.
    • This reply was modified 5 years, 1 month ago by neoseo1300.
    hannah

    (@hannahritner)

    Glad things are working!

    Hannah

    Thread Starter rambo3000

    (@rambo3000)

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Available placeholders are very limited’ is closed to new replies.