hello Mike
You can try this code
// merge 3 fields to Shipping Address 1
add_filter('woe_get_order_value_shipping_address_1',function ($value, $order,$fieldname) {
return get_post_meta($order->id,'_shipping_address_1',true).' '.get_post_meta($order->id,'_shipping_address_2',true).' '.get_post_meta($order->id,'_shipping_address_3',true);
},10,3);
We plan to code field constructor in version 2.0 only.
thanks, Alex
ops, here is corrected version
// merge 3 fields to Shipping Address 1
add_filter('woe_get_order_value_shipping_address_1',function ($value, $order,$fieldname) {
return get_post_meta($order->id,'_shipping_address_1',true).' '.get_post_meta($order->id,'_shipping_address_2',true).' '.get_post_meta($order->id,'_shipping_city',true);
},10,3);
Hello Alex!
That worked perfectly thank you,
but I forgot to mention that I need to merge State column as well
so I added below code at the end
.' '.get_post_meta($order->id,'_shipping_state',true);
But it’s giving me state code instead of state name.
Am I doing something wrong?
Thank you very much,
Mike
// merge shipping fields to Shipping Address 1
add_filter('woe_get_order_value_shipping_address_1',function ($value, $order,$fieldname) {
$state = get_post_meta($order->id,'_shipping_state',true);
$country = get_post_meta($order->id,'_shipping_country',true);
$country_states = WC()->countries->get_states( $country );
if( isset( $country_states[$state]) ) // has full name ?
$state = html_entity_decode( $country_states[ $state ] ) ;
$parts = array();
$parts[] = get_post_meta($order->id,'_shipping_address_1',true);
$parts[] = get_post_meta($order->id,'_shipping_address_2',true);
$parts[] = get_post_meta($order->id,'_shipping_city',true);
$parts[] = $state;
$parts = array_filter($parts);
return join(" ", $parts);
},10,3);
Oh wow that worked perfectly!
Thank you very much for your help!