<?php
add_filter( 'woocommerce_get_order_address', 'tzn_custom_woocommerce_get_order_address_filter', 10, 3 );
function tzn_custom_woocommerce_get_order_address_filter( $address_data, $address_type, $that ){
if(is_wc_endpoint_url('order-received')){
if($address_type == 'billing'){
$billing_title = '';
if ( $that->billing_title == 1 ) {
$billing_title = esc_html__( 'Mann', 'tzn' );
} else if ( $that->billing_title == 2 ) {
$billing_title = esc_html__( 'Herr', 'tzn' );
}
if(!isset($address_data['title']) && $billing_title != ""){
$address_data = array_merge(['title' => $billing_title], $address_data);
}
}
if($address_type == 'shipping'){
$shipping_title = '';
if ( $that->shipping_title == 1 ) {
$shipping_title = esc_html__( 'Mann', 'tzn' );
} else if ( $that->shipping_title == 2 ) {
$shipping_title = esc_html__( 'Herr', 'tzn' );
}
if(!isset($address_data['title']) && $shipping_title != ""){
$address_data = array_merge(['title' => $shipping_title], $address_data);
}
}
}
return $address_data;
}
?>