• Hi Woocommerce team

    Please see this,

    I have added the following code to my function.php to create some custom field in WC Vendors shop settings.

    /*Merchant Phone number custom field*/
    add_action('wcvendors_settings_after_paypal', 'pv_add_custom_phone_field');
    function pv_add_custom_phone_field() {
        ?>
        <div class="pv_phone_container">
          <p><b><?php _e( 'Phone number', 'wc_product_vendor' ); ?></b><br/>
            <?php _e( 'Your active phone number', 'wc_product_vendor' ); ?><br/>
    
            <input type="text" name="pv_phone" id="pv_phone" placeholder="" value="<?php echo get_user_meta( get_current_user_id(), 'pv_phone', true ); ?>" />
          </p>
        </div>
        <?php
      }
    
    add_action( 'wcvendors_shop_settings_saved', 'pv_save_phone' );
    add_action( 'wcvendors_update_admin_user', 'pv_save_phone' );
    
    function pv_save_phone( $user_id )
    {
      update_user_meta( $user_id, 'pv_phone', $_POST['pv_phone'] );
    }

    And added following code to send the vendor details in order email

    add_filter('woocommerce_email_order_meta_keys', 'email_vendor_details');
    add_action( 'woocommerce_single_product_summary', 'email_vendor_details', 10 );
    function email_vendor_details() {
    	global $post;
    	?><h2><?php _e( 'Vendor details', 'woocommerce' ); ?></h2><?php
      	$author_id=$post->post_author;
      	echo "<ul>";
    	echo '<li><Strong>Bakery Name: </strong><span style="color:#000;">'.get_user_meta( $author_id, 'pv_shop_name', true ).'</span></li>';
    	echo '<li><Strong>Tel: </strong><span style="color:#000;">'.get_user_meta( $author_id, 'pv_phone', true ).'</span></li>';
    	echo '<li><Strong>Address: </strong><span style="color:#000;">'.get_user_meta( $author_id, 'pv_address', true ).'</span></li>';
    	echo "</ul>";
    	return true;
    }

    1. It’s showing the Vendor details perfect in Product single page. (Screenshot is attached http://i66.tinypic.com/1037gp0.jpg)
    2. But it’s not showing in email. (Screenshot is attached http://i67.tinypic.com/2uf3rx4.jpg)

    Please tell, how can I make it done.

    https://wordpress.org/plugins/woocommerce/

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Custom field not showing in order email’ is closed to new replies.