Support » Plugin: Where Did You Hear About Us Checkout Field for WooCommerce » Selected Referer in New Order Email

  • Resolved pixelcellar

    (@pixelcellar)


    Is it possible to have the selected option output into the New Order email as part of the functionality or tell me how I can add this in there. Otherwise this plugin is brilliant 🙂

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author wooassist

    (@wooassist)

    Hi,

    Currently it’s not possible to add it on the New Order Email template. You can try to check this documentation to add the field on your new order email template https://docs.woocommerce.com/document/add-a-custom-field-in-an-order-to-the-emails/

    Thanks for coming back to me, I found that or similar to it at least after I’d posted.

    So that it potentially adds someone else going forward here’s the code to add to the themes functions.php:

    add_filter(‘woocommerce_email_order_meta_keys’, ‘my_woocommerce_email_order_meta_keys’);

    function my_woocommerce_email_order_meta_keys( $keys ) {
    echo ‘<h2>Miscellaneous Details</h2>’;
    $keys[‘Referred by’] = ‘wc_customer_source_checkout_field’;
    $keys[‘Other Reason’] = ‘wc_customer_source_checkout_other_field’;
    return $keys;
    }

    If anyone has a tidier way of adding the “Other Reason” field then feel free to add your version, on the plus side if the user chooses one of your defined options then the “Other Reason” label etc isn’t displayed so it pretty much works tidily.

    Plugin Author wooassist

    (@wooassist)

    Hi,

    I’m glad you found a way to make it work. In our next update we will add a feature to add this field on the new order email template.

    @pixelcellar, Thank you so much for the code, I was trying to figure it out myself 🙂

    I put the code into the functions file of my clients child theme

    add_filter(‘woocommerce_email_order_meta_keys’, ‘my_woocommerce_email_order_meta_keys’);

    function my_woocommerce_email_order_meta_keys( $keys ) {
    echo ‘<h2>Miscellaneous Details</h2>’;
    $keys[‘Where did you hear about us?’] = ‘wc_customer_source_checkout_field’;
    $keys[‘Other’] = ‘wc_customer_source_checkout_other_field’;
    return $keys;
    }

    but get this error
    Parse error: syntax error, unexpected ‘Details’’ (T_STRING), expecting ‘,’ or ‘;’ in /home/casoro/public_html/wp-content/themes/salient-child/functions.php on line 157

    Here is a screenshot of the code in the file
    http://www.clipular.com/c/5250961420582912.png?k=m1iRuvNI-ITuL20b9YM9eoXxjho

    Any help would be great 🙂

    Thank you
    Tanya

    Hi Tanya

    Sorry for not replying sooner, just got back from holidays.

    Assuming the quotes are correct, ie like [ ‘ ] I’m not 100% sure what the issue could be. Try making them all like they are in the function above in the screenshot you attachedm, they are more straight lines as opposed to the more curly quotes in what I attached which has been formatted by this site.

    Plugin Author wooassist

    (@wooassist)

    @pixelcellar thank you for you help on this, much appreciated.

    @teclive We have not heard from you in a while, I assume the issue has been resolved now? I will mark this thread as resolved.If you need further help please let us know, Thanks!

    pixelcellar

    (@pixelcellar)

    Just out of interest, is there a tidier method of doing this as yet? You mentioned in an earlier entry in this thread (https://wordpress.org/support/topic/selected-referer-in-new-order-email/#post-9394587) that this was something that would be included and made easier?

    If this has been done could you advise to make this thread be even more useful for others looking for a similar thing?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Selected Referer in New Order Email’ is closed to new replies.