• Hi guys, I am in serious need of some help.
    On my website when you purchase something, I get sent an email with information of what has been purchased as well as your email adress.
    Now,I have added a custom field where you type in your phone number. The field works just fine but in the email I receive, I do not get the number you typed it. The email just says: Phone:

    Again, the email adress gets shown correctly, but now the phone number. So, I hope we can figure out what I am missing or doing wrong. I have copied the code for the email (which works) and the code I have made for the phone number below.

    In the email that gets sent, this is the PHP code:

    echo __( 'Email:', 'ywraq' ); echo $raq_data['user_email'] . "\n";
    echo __( 'Phone:', 'ywraq' ); echo $plain_text['user_phone'] . "\n";

    This is the PHP code for the email found in the form of the checkout:

    <p class="form-row form-row-wide validate-required" id="rqa_email_row">
                    <label for="rqa-email" class=""><?php _e( 'Email', 'ywraq' ) ?>
                        <abbr class="required" title="required">*</abbr></label>
                    <input type="email" class="input-text " name="rqa_email" id="rqa-email" placeholder="" value="<?php echo $user_email ?>" required>
                </p>

    And finally, the one I added for the phone number:

    <p class="form-row form-row-wide validate-required" id="rqa_phone_row">
                    <label for="rqa-phone" class=""><?php _e( 'Phone', 'ywraq' ) ?>
                        <abbr class="required" title="required">*</abbr></label>
                    <input type="text" class="input-text " phone="rqa_phone" id="rqa-phone" placeholder="" value="<?php echo $user_phone ?>" required>
                </p>

    Anyone with an idea of what I need to do in order to get the phone number shown in the email as well?
    Hoping for some help, this has been killing me.

    Thanks in advance.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator bcworkz

    (@bcworkz)

    Hi komani,
    You site is using WooCommerce, correct? The Woo user interface should collect and display customer telephone numbers by default, no special coding required.

    Anyway, for any custom field added, you typically need special code for each step. Woo provides all manner of hooks, the challenge is to find the correct one, their code is very difficult to trace, going through many different files, functions, filters, templates, etc.

    Besides adding the form field, you need code hooked into where the form is handled to store the form data. I don’t see this happening in the code you posted. Then to output the data in an email or on screen, or where ever, the field value is retrieved from where ever it was stored. I don’t see this either.

    Even assuming that is all handled else where, I would think the phone would be in the same array as the email, so $raq_data['user_phone'] since the email part works. Just a hunch, I’ve no evidence to support this.

    You haven’t provided us with enough code and context to be sure everything is as it should be. Each snippet you’ve provided looks OK on its own, but we can’t tell how they all connect.

    Just a reminder, if you need to post a lot of code (the 3 segments above are fine), please use pastebin.com instead of posting here. It’s also helpful to select the correct syntax highlighting when you publish in pastebin. TIA.

    Thread Starter komani

    (@komani)

    Thanks for your reply! Appreciate the help. Yes, using WooCommerce.
    That’s just the thing! $raq_data[‘user_phone’] should work just like the email but I can’t figure out why it won’t!

    The two files I have been editing and working on the most are these (github links):

    http://www.codingforums.com/redirect-to/?redirect=https%3A%2F%2Fgithub.com%2Fwp-plugins%2Fyith-woocommerce-request-a-quote%2Fblob%2Fmaster%2Ftemplates%2Frequest-quote-form.php

    https://github.com/wp-plugins/yith-woocommerce-request-a-quote/blob/master/templates/emails/request-quote.php

    You can see near the bottom of the second file there is a line ‘Customer details’. Below there is where I am trying to add phone number.

    Pretty much only things I added were the lines from the OP. It is just strange how it shows the email adress correctly but not the phone number…

    Moderator bcworkz

    (@bcworkz)

    So this is actually an extension to Woo for quotations? That would explain why the usual Woo telephone field is missing. You could try adding print_r( $raq_data, true ); to the email to view all the available fields, perhaps it’s “user_tel” or something. Print_r will reveal.

    If it’s not there at all, we’d need to see the code that stores the form data in order to know how to get it out of the DB. Look at the form’s source HTML for the <form> tag’s action attribute to see where the form is submitted. The code for that location is likely storing the value, but exactly where that is could be buried through several levels of functions. Finding where those functions are defined is where working with Woo (or extensions written in similar style) can drive one crazy!

    Thread Starter komani

    (@komani)

    Just tried both user_tel and print_r( $raq_data, true );
    It didn’t change a thing 🙁

    What about this:
    <?php do_action( ‘yith_ywraq_email_before_raq_table’, $raq_data ); ?>

    Can’t seem to find this table anywhere but I’d guess that would be the source?

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Displaying email and phone number’ is closed to new replies.