Multi Vendor - How to hide email and phone number of the customer in the "new order email vendor"

If you want  hide email and phone number of the customer in the "new order email vendor" you can use this code. Paste this in your functions.php of your theme:

For WooCommerce version 3.1.x or lower

if( function_exists( 'YITH_Vendors' ) ){
add_filter( 'woocommerce_email_customer_details_fields', 'yith_woocommerce_email_customer_details_fields', 10, 3 );

if( ! function_exists( 'yith_woocommerce_email_customer_details_fields' ) ){
function yith_woocommerce_email_customer_details_fields( $fields, $sent_to_admin, $order ){
if( $order instanceof WC_Order && wp_get_post_parent_id( $order->get_id() ) != 0 ){
$fields_to_remove = array( 'billing_email', 'billing_phone' );
foreach( $fields_to_remove as $to_remove ){
if( isset( $fields[ $to_remove ] ) ){
unset( $fields[ $to_remove ] );
}
}
}
return $fields;
}
}
}

For WooCommerce version 3.2.x or greather

if( function_exists( 'YITH_Vendors' ) ) {
add_filter( 'woocommerce_order_get_billing_email', 'yith_woocommerce_email_customer_details_fields', 10, 2 );
add_filter( 'woocommerce_order_get_billing_phone', 'yith_woocommerce_email_customer_details_fields', 10, 2 );

if ( ! function_exists( 'yith_woocommerce_email_customer_details_fields' ) ) {
function yith_woocommerce_email_customer_details_fields( $value, $order ) {
if ( $order instanceof WC_Order && wp_get_post_parent_id( $order->get_id() ) != 0 ) {
$value = '';
}

return $value;
}
}
}
Was this article helpful?
0 out of 0 found this helpful

Back to Help Center

Powered by Zendesk