Support » Plugin: WooCommerce » Send Custom Field with Order Email Woocomerce

  • The code below shows my custom field on my product page and billing page. Can somebody please explain what i need to add to have the field value sent with the woocommerce order to my email once complete

    snippet—-

    add_action( ‘woocommerce_after_checkout_billing_form’, ‘add_user_field_to_checkout’ );

    function add_user_field_to_checkout( $checkout ) {

    $current_user = wp_get_current_user();
    $saved_url = $current_user->front_door_key;

    woocommerce_form_field( ‘front_door_key’, array(
    ‘type’ => ‘text’,
    ‘class’ => array(‘user_url form-row-wide’),
    ‘label’ => __(‘Front Door Key Code’),
    ‘placeholder’ => __(‘Key Code’),
    ‘required’ => true
    ),
    $saved_url );

    }
    add_action( ‘woocommerce_before_add_to_cart_button’, ‘add_user_field_to_checkout’ );

    function woocommerce_before_add_to_cart_button( $checkout ) {

    $current_user = wp_get_current_user();
    $saved_url = $current_user->front_door_key;

    woocommerce_form_field( ‘front_door_key’, array(
    ‘type’ => ‘text’,
    ‘class’ => array(‘user_url form-row-wide’),
    ‘label’ => __(‘Front Door Key Code’),
    ‘placeholder’ => __(‘Key code ‘),
    ‘required’ => true
    ),
    $saved_url );

    }

    —snippet ends

    • This topic was modified 10 months, 2 weeks ago by vertexmedia.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Send Custom Field with Order Email Woocomerce’ is closed to new replies.